<html><!-- Created using the cpp_pretty_printer from the dlib C++ library.  See http://dlib.net for updates. --><head><title>dlib C++ Library - interpolation.h</title></head><body bgcolor='white'><pre>
<font color='#009900'>// Copyright (C) 2012  Davis E. King (davis@dlib.net)
</font><font color='#009900'>// License: Boost Software License   See LICENSE.txt for the full license.
</font><font color='#0000FF'>#ifndef</font> DLIB_INTERPOlATIONh_
<font color='#0000FF'>#define</font> DLIB_INTERPOlATIONh_ 

<font color='#0000FF'>#include</font> "<a style='text-decoration:none' href='interpolation_abstract.h.html'>interpolation_abstract.h</a>"
<font color='#0000FF'>#include</font> "<a style='text-decoration:none' href='../pixel.h.html'>../pixel.h</a>"
<font color='#0000FF'>#include</font> "<a style='text-decoration:none' href='../matrix.h.html'>../matrix.h</a>"
<font color='#0000FF'>#include</font> "<a style='text-decoration:none' href='assign_image.h.html'>assign_image.h</a>"
<font color='#0000FF'>#include</font> "<a style='text-decoration:none' href='image_pyramid.h.html'>image_pyramid.h</a>"
<font color='#0000FF'>#include</font> "<a style='text-decoration:none' href='../simd.h.html'>../simd.h</a>"
<font color='#0000FF'>#include</font> "<a style='text-decoration:none' href='../image_processing/full_object_detection.h.html'>../image_processing/full_object_detection.h</a>"

<font color='#0000FF'>namespace</font> dlib
<b>{</b>

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font><font color='#0000FF'>typename</font> T<font color='#5555FF'>&gt;</font>
    <font color='#0000FF'>struct</font> <b><a name='sub_image_proxy'></a>sub_image_proxy</b>
    <b>{</b>
        <b><a name='sub_image_proxy'></a>sub_image_proxy</b> <font face='Lucida Console'>(</font>
            T<font color='#5555FF'>&amp;</font> img,
            rectangle rect
        <font face='Lucida Console'>)</font> 
        <b>{</b>
            rect <font color='#5555FF'>=</font> rect.<font color='#BB00BB'>intersect</font><font face='Lucida Console'>(</font><font color='#BB00BB'>get_rect</font><font face='Lucida Console'>(</font>img<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
            <font color='#0000FF'>typedef</font> <font color='#0000FF'>typename</font> image_traits<font color='#5555FF'>&lt;</font>T<font color='#5555FF'>&gt;</font>::pixel_type pixel_type;

            _nr <font color='#5555FF'>=</font> rect.<font color='#BB00BB'>height</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;
            _nc <font color='#5555FF'>=</font> rect.<font color='#BB00BB'>width</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;
            _width_step <font color='#5555FF'>=</font> <font color='#BB00BB'>width_step</font><font face='Lucida Console'>(</font>img<font face='Lucida Console'>)</font>;
            _data <font color='#5555FF'>=</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>char</u></font><font color='#5555FF'>*</font><font face='Lucida Console'>)</font><font color='#BB00BB'>image_data</font><font face='Lucida Console'>(</font>img<font face='Lucida Console'>)</font> <font color='#5555FF'>+</font> <font color='#0000FF'>sizeof</font><font face='Lucida Console'>(</font>pixel_type<font face='Lucida Console'>)</font><font color='#5555FF'>*</font>rect.<font color='#BB00BB'>left</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>+</font> rect.<font color='#BB00BB'>top</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font color='#5555FF'>*</font>_width_step;
        <b>}</b>

        <font color='#0000FF'><u>void</u></font><font color='#5555FF'>*</font> _data;
        <font color='#0000FF'><u>long</u></font> _width_step;
        <font color='#0000FF'><u>long</u></font> _nr;
        <font color='#0000FF'><u>long</u></font> _nc;
    <b>}</b>;

    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font><font color='#0000FF'>typename</font> T<font color='#5555FF'>&gt;</font>
    <font color='#0000FF'>struct</font> <b><a name='const_sub_image_proxy'></a>const_sub_image_proxy</b>
    <b>{</b>
        <b><a name='const_sub_image_proxy'></a>const_sub_image_proxy</b> <font face='Lucida Console'>(</font>
            <font color='#0000FF'>const</font> T<font color='#5555FF'>&amp;</font> img,
            rectangle rect
        <font face='Lucida Console'>)</font> 
        <b>{</b>
            rect <font color='#5555FF'>=</font> rect.<font color='#BB00BB'>intersect</font><font face='Lucida Console'>(</font><font color='#BB00BB'>get_rect</font><font face='Lucida Console'>(</font>img<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
            <font color='#0000FF'>typedef</font> <font color='#0000FF'>typename</font> image_traits<font color='#5555FF'>&lt;</font>T<font color='#5555FF'>&gt;</font>::pixel_type pixel_type;

            _nr <font color='#5555FF'>=</font> rect.<font color='#BB00BB'>height</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;
            _nc <font color='#5555FF'>=</font> rect.<font color='#BB00BB'>width</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;
            _width_step <font color='#5555FF'>=</font> <font color='#BB00BB'>width_step</font><font face='Lucida Console'>(</font>img<font face='Lucida Console'>)</font>;
            _data <font color='#5555FF'>=</font> <font face='Lucida Console'>(</font><font color='#0000FF'>const</font> <font color='#0000FF'><u>char</u></font><font color='#5555FF'>*</font><font face='Lucida Console'>)</font><font color='#BB00BB'>image_data</font><font face='Lucida Console'>(</font>img<font face='Lucida Console'>)</font> <font color='#5555FF'>+</font> <font color='#0000FF'>sizeof</font><font face='Lucida Console'>(</font>pixel_type<font face='Lucida Console'>)</font><font color='#5555FF'>*</font>rect.<font color='#BB00BB'>left</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>+</font> rect.<font color='#BB00BB'>top</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font color='#5555FF'>*</font>_width_step;
        <b>}</b>

        <font color='#0000FF'>const</font> <font color='#0000FF'><u>void</u></font><font color='#5555FF'>*</font> _data;
        <font color='#0000FF'><u>long</u></font> _width_step;
        <font color='#0000FF'><u>long</u></font> _nr;
        <font color='#0000FF'><u>long</u></font> _nc;
    <b>}</b>;

    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font><font color='#0000FF'>typename</font> T<font color='#5555FF'>&gt;</font>
    <font color='#0000FF'>struct</font> <b><a name='image_traits'></a>image_traits</b><font color='#5555FF'>&lt;</font>sub_image_proxy<font color='#5555FF'>&lt;</font>T<font color='#5555FF'>&gt;</font> <font color='#5555FF'>&gt;</font>
    <b>{</b>
        <font color='#0000FF'>typedef</font> <font color='#0000FF'>typename</font> image_traits<font color='#5555FF'>&lt;</font>T<font color='#5555FF'>&gt;</font>::pixel_type pixel_type;
    <b>}</b>;
    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font><font color='#0000FF'>typename</font> T<font color='#5555FF'>&gt;</font>
    <font color='#0000FF'>struct</font> <b><a name='image_traits'></a>image_traits</b><font color='#5555FF'>&lt;</font><font color='#0000FF'>const</font> sub_image_proxy<font color='#5555FF'>&lt;</font>T<font color='#5555FF'>&gt;</font> <font color='#5555FF'>&gt;</font>
    <b>{</b>
        <font color='#0000FF'>typedef</font> <font color='#0000FF'>typename</font> image_traits<font color='#5555FF'>&lt;</font>T<font color='#5555FF'>&gt;</font>::pixel_type pixel_type;
    <b>}</b>;
    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font><font color='#0000FF'>typename</font> T<font color='#5555FF'>&gt;</font>
    <font color='#0000FF'>struct</font> <b><a name='image_traits'></a>image_traits</b><font color='#5555FF'>&lt;</font>const_sub_image_proxy<font color='#5555FF'>&lt;</font>T<font color='#5555FF'>&gt;</font> <font color='#5555FF'>&gt;</font>
    <b>{</b>
        <font color='#0000FF'>typedef</font> <font color='#0000FF'>typename</font> image_traits<font color='#5555FF'>&lt;</font>T<font color='#5555FF'>&gt;</font>::pixel_type pixel_type;
    <b>}</b>;
    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font><font color='#0000FF'>typename</font> T<font color='#5555FF'>&gt;</font>
    <font color='#0000FF'>struct</font> <b><a name='image_traits'></a>image_traits</b><font color='#5555FF'>&lt;</font><font color='#0000FF'>const</font> const_sub_image_proxy<font color='#5555FF'>&lt;</font>T<font color='#5555FF'>&gt;</font> <font color='#5555FF'>&gt;</font>
    <b>{</b>
        <font color='#0000FF'>typedef</font> <font color='#0000FF'>typename</font> image_traits<font color='#5555FF'>&lt;</font>T<font color='#5555FF'>&gt;</font>::pixel_type pixel_type;
    <b>}</b>;

    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font><font color='#0000FF'>typename</font> T<font color='#5555FF'>&gt;</font>
    <font color='#0000FF'>inline</font> <font color='#0000FF'><u>long</u></font> <b><a name='num_rows'></a>num_rows</b><font face='Lucida Console'>(</font> <font color='#0000FF'>const</font> sub_image_proxy<font color='#5555FF'>&lt;</font>T<font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> img<font face='Lucida Console'>)</font> <b>{</b> <font color='#0000FF'>return</font> img._nr; <b>}</b>
    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font><font color='#0000FF'>typename</font> T<font color='#5555FF'>&gt;</font>
    <font color='#0000FF'>inline</font> <font color='#0000FF'><u>long</u></font> <b><a name='num_columns'></a>num_columns</b><font face='Lucida Console'>(</font> <font color='#0000FF'>const</font> sub_image_proxy<font color='#5555FF'>&lt;</font>T<font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> img<font face='Lucida Console'>)</font> <b>{</b> <font color='#0000FF'>return</font> img._nc; <b>}</b>

    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font><font color='#0000FF'>typename</font> T<font color='#5555FF'>&gt;</font>
    <font color='#0000FF'>inline</font> <font color='#0000FF'><u>long</u></font> <b><a name='num_rows'></a>num_rows</b><font face='Lucida Console'>(</font> <font color='#0000FF'>const</font> const_sub_image_proxy<font color='#5555FF'>&lt;</font>T<font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> img<font face='Lucida Console'>)</font> <b>{</b> <font color='#0000FF'>return</font> img._nr; <b>}</b>
    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font><font color='#0000FF'>typename</font> T<font color='#5555FF'>&gt;</font>
    <font color='#0000FF'>inline</font> <font color='#0000FF'><u>long</u></font> <b><a name='num_columns'></a>num_columns</b><font face='Lucida Console'>(</font> <font color='#0000FF'>const</font> const_sub_image_proxy<font color='#5555FF'>&lt;</font>T<font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> img<font face='Lucida Console'>)</font> <b>{</b> <font color='#0000FF'>return</font> img._nc; <b>}</b>

    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font><font color='#0000FF'>typename</font> T<font color='#5555FF'>&gt;</font>
    <font color='#0000FF'>inline</font> <font color='#0000FF'><u>void</u></font><font color='#5555FF'>*</font> <b><a name='image_data'></a>image_data</b><font face='Lucida Console'>(</font> sub_image_proxy<font color='#5555FF'>&lt;</font>T<font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> img<font face='Lucida Console'>)</font> 
    <b>{</b> 
        <font color='#0000FF'>return</font> img._data; 
    <b>}</b> 
    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font><font color='#0000FF'>typename</font> T<font color='#5555FF'>&gt;</font>
    <font color='#0000FF'>inline</font> <font color='#0000FF'>const</font> <font color='#0000FF'><u>void</u></font><font color='#5555FF'>*</font> <b><a name='image_data'></a>image_data</b><font face='Lucida Console'>(</font> <font color='#0000FF'>const</font> sub_image_proxy<font color='#5555FF'>&lt;</font>T<font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> img<font face='Lucida Console'>)</font> 
    <b>{</b>
        <font color='#0000FF'>return</font> img._data; 
    <b>}</b>

    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font><font color='#0000FF'>typename</font> T<font color='#5555FF'>&gt;</font>
    <font color='#0000FF'>inline</font> <font color='#0000FF'>const</font> <font color='#0000FF'><u>void</u></font><font color='#5555FF'>*</font> <b><a name='image_data'></a>image_data</b><font face='Lucida Console'>(</font> <font color='#0000FF'>const</font> const_sub_image_proxy<font color='#5555FF'>&lt;</font>T<font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> img<font face='Lucida Console'>)</font> 
    <b>{</b>
        <font color='#0000FF'>return</font> img._data; 
    <b>}</b>

    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font><font color='#0000FF'>typename</font> T<font color='#5555FF'>&gt;</font>
    <font color='#0000FF'>inline</font> <font color='#0000FF'><u>long</u></font> <b><a name='width_step'></a>width_step</b><font face='Lucida Console'>(</font>
        <font color='#0000FF'>const</font> sub_image_proxy<font color='#5555FF'>&lt;</font>T<font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> img
    <font face='Lucida Console'>)</font> <b>{</b> <font color='#0000FF'>return</font> img._width_step; <b>}</b>

    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font><font color='#0000FF'>typename</font> T<font color='#5555FF'>&gt;</font>
    <font color='#0000FF'>inline</font> <font color='#0000FF'><u>long</u></font> <b><a name='width_step'></a>width_step</b><font face='Lucida Console'>(</font>
        <font color='#0000FF'>const</font> const_sub_image_proxy<font color='#5555FF'>&lt;</font>T<font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> img
    <font face='Lucida Console'>)</font> <b>{</b> <font color='#0000FF'>return</font> img._width_step; <b>}</b>

    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font><font color='#0000FF'>typename</font> T<font color='#5555FF'>&gt;</font>
    <font color='#0000FF'><u>void</u></font> <b><a name='set_image_size'></a>set_image_size</b><font face='Lucida Console'>(</font>sub_image_proxy<font color='#5555FF'>&lt;</font>T<font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> img, <font color='#0000FF'><u>long</u></font> rows, <font color='#0000FF'><u>long</u></font> cols<font face='Lucida Console'>)</font>
    <b>{</b>
        <font color='#BB00BB'>DLIB_CASSERT</font><font face='Lucida Console'>(</font>img._nr <font color='#5555FF'>=</font><font color='#5555FF'>=</font> rows <font color='#5555FF'>&amp;</font><font color='#5555FF'>&amp;</font> img._nc <font color='#5555FF'>=</font><font color='#5555FF'>=</font> cols, "<font color='#CC0000'>A sub_image can't be resized.</font>"
            <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t img._nr: </font>"<font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> img._nr
            <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t img._nc: </font>"<font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> img._nc
            <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t rows:    </font>"<font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> rows
            <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t cols:    </font>"<font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> cols
            <font face='Lucida Console'>)</font>;
    <b>}</b>

    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font>
        <font color='#0000FF'>typename</font> image_type
        <font color='#5555FF'>&gt;</font>
    sub_image_proxy<font color='#5555FF'>&lt;</font>image_type<font color='#5555FF'>&gt;</font> <b><a name='sub_image'></a>sub_image</b> <font face='Lucida Console'>(</font>
        image_type<font color='#5555FF'>&amp;</font> img,
        <font color='#0000FF'>const</font> rectangle<font color='#5555FF'>&amp;</font> rect
    <font face='Lucida Console'>)</font>
    <b>{</b>
        <font color='#0000FF'>return</font> sub_image_proxy<font color='#5555FF'>&lt;</font>image_type<font color='#5555FF'>&gt;</font><font face='Lucida Console'>(</font>img,rect<font face='Lucida Console'>)</font>;
    <b>}</b>

    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font>
        <font color='#0000FF'>typename</font> image_type
        <font color='#5555FF'>&gt;</font>
    <font color='#0000FF'>const</font> const_sub_image_proxy<font color='#5555FF'>&lt;</font>image_type<font color='#5555FF'>&gt;</font> <b><a name='sub_image'></a>sub_image</b> <font face='Lucida Console'>(</font>
        <font color='#0000FF'>const</font> image_type<font color='#5555FF'>&amp;</font> img,
        <font color='#0000FF'>const</font> rectangle<font color='#5555FF'>&amp;</font> rect
    <font face='Lucida Console'>)</font>
    <b>{</b>
        <font color='#0000FF'>return</font> const_sub_image_proxy<font color='#5555FF'>&lt;</font>image_type<font color='#5555FF'>&gt;</font><font face='Lucida Console'>(</font>img,rect<font face='Lucida Console'>)</font>;
    <b>}</b>

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font><font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
    <font color='#0000FF'>class</font> <b><a name='interpolate_nearest_neighbor'></a>interpolate_nearest_neighbor</b>
    <b>{</b>
    <font color='#0000FF'>public</font>:

        <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font><font color='#0000FF'>typename</font> image_view_type, <font color='#0000FF'>typename</font> pixel_type<font color='#5555FF'>&gt;</font>
        <font color='#0000FF'><u>bool</u></font> <b><a name='operator'></a>operator</b><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font face='Lucida Console'>(</font>
            <font color='#0000FF'>const</font> image_view_type<font color='#5555FF'>&amp;</font> img,
            <font color='#0000FF'>const</font> dlib::point<font color='#5555FF'>&amp;</font> p,
            pixel_type<font color='#5555FF'>&amp;</font> result
        <font face='Lucida Console'>)</font> <font color='#0000FF'>const</font>
        <b>{</b>
            <font color='#BB00BB'>COMPILE_TIME_ASSERT</font><font face='Lucida Console'>(</font>pixel_traits<font color='#5555FF'>&lt;</font><font color='#0000FF'>typename</font> image_view_type::pixel_type<font color='#5555FF'>&gt;</font>::has_alpha <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>false</font><font face='Lucida Console'>)</font>;

            <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font><font color='#BB00BB'>get_rect</font><font face='Lucida Console'>(</font>img<font face='Lucida Console'>)</font>.<font color='#BB00BB'>contains</font><font face='Lucida Console'>(</font>p<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>
            <b>{</b>
                <font color='#BB00BB'>assign_pixel</font><font face='Lucida Console'>(</font>result, img[p.<font color='#BB00BB'>y</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>][p.<font color='#BB00BB'>x</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>]<font face='Lucida Console'>)</font>;
                <font color='#0000FF'>return</font> <font color='#979000'>true</font>;
            <b>}</b>
            <font color='#0000FF'>else</font>
            <b>{</b>
                <font color='#0000FF'>return</font> <font color='#979000'>false</font>;
            <b>}</b>
        <b>}</b>

    <b>}</b>;

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
    <font color='#0000FF'>class</font> <b><a name='interpolate_bilinear'></a>interpolate_bilinear</b>
    <b>{</b>
        <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font><font color='#0000FF'>typename</font> T<font color='#5555FF'>&gt;</font>
        <font color='#0000FF'>struct</font> <b><a name='is_rgb_image'></a>is_rgb_image</b> 
        <b>{</b>
            <font color='#0000FF'>const</font> <font color='#0000FF'>static</font> <font color='#0000FF'><u>bool</u></font> value <font color='#5555FF'>=</font> pixel_traits<font color='#5555FF'>&lt;</font><font color='#0000FF'>typename</font> T::pixel_type<font color='#5555FF'>&gt;</font>::rgb;
        <b>}</b>;

    <font color='#0000FF'>public</font>:

        <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font><font color='#0000FF'>typename</font> T, <font color='#0000FF'>typename</font> image_view_type, <font color='#0000FF'>typename</font> pixel_type<font color='#5555FF'>&gt;</font>
        <font color='#0000FF'>typename</font> disable_if<font color='#5555FF'>&lt;</font>is_rgb_image<font color='#5555FF'>&lt;</font>image_view_type<font color='#5555FF'>&gt;</font>,<font color='#0000FF'><u>bool</u></font><font color='#5555FF'>&gt;</font>::type <b><a name='operator'></a>operator</b><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font face='Lucida Console'>(</font>
            <font color='#0000FF'>const</font> image_view_type<font color='#5555FF'>&amp;</font> img,
            <font color='#0000FF'>const</font> dlib::vector<font color='#5555FF'>&lt;</font>T,<font color='#979000'>2</font><font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> p,
            pixel_type<font color='#5555FF'>&amp;</font> result
        <font face='Lucida Console'>)</font> <font color='#0000FF'>const</font>
        <b>{</b>
            <font color='#BB00BB'>COMPILE_TIME_ASSERT</font><font face='Lucida Console'>(</font>pixel_traits<font color='#5555FF'>&lt;</font><font color='#0000FF'>typename</font> image_view_type::pixel_type<font color='#5555FF'>&gt;</font>::has_alpha <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>false</font><font face='Lucida Console'>)</font>;

            <font color='#0000FF'>const</font> <font color='#0000FF'><u>long</u></font> left   <font color='#5555FF'>=</font> <font color='#0000FF'>static_cast</font><font color='#5555FF'>&lt;</font><font color='#0000FF'><u>long</u></font><font color='#5555FF'>&gt;</font><font face='Lucida Console'>(</font>std::<font color='#BB00BB'>floor</font><font face='Lucida Console'>(</font>p.<font color='#BB00BB'>x</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
            <font color='#0000FF'>const</font> <font color='#0000FF'><u>long</u></font> top    <font color='#5555FF'>=</font> <font color='#0000FF'>static_cast</font><font color='#5555FF'>&lt;</font><font color='#0000FF'><u>long</u></font><font color='#5555FF'>&gt;</font><font face='Lucida Console'>(</font>std::<font color='#BB00BB'>floor</font><font face='Lucida Console'>(</font>p.<font color='#BB00BB'>y</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
            <font color='#0000FF'>const</font> <font color='#0000FF'><u>long</u></font> right  <font color='#5555FF'>=</font> left<font color='#5555FF'>+</font><font color='#979000'>1</font>;
            <font color='#0000FF'>const</font> <font color='#0000FF'><u>long</u></font> bottom <font color='#5555FF'>=</font> top<font color='#5555FF'>+</font><font color='#979000'>1</font>;


            <font color='#009900'>// if the interpolation goes outside img 
</font>            <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font><font color='#5555FF'>!</font><font face='Lucida Console'>(</font>left <font color='#5555FF'>&gt;</font><font color='#5555FF'>=</font> <font color='#979000'>0</font> <font color='#5555FF'>&amp;</font><font color='#5555FF'>&amp;</font> top <font color='#5555FF'>&gt;</font><font color='#5555FF'>=</font> <font color='#979000'>0</font> <font color='#5555FF'>&amp;</font><font color='#5555FF'>&amp;</font> right <font color='#5555FF'>&lt;</font> img.<font color='#BB00BB'>nc</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>&amp;</font><font color='#5555FF'>&amp;</font> bottom <font color='#5555FF'>&lt;</font> img.<font color='#BB00BB'>nr</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>
                <font color='#0000FF'>return</font> <font color='#979000'>false</font>;

            <font color='#0000FF'>const</font> <font color='#0000FF'><u>double</u></font> lr_frac <font color='#5555FF'>=</font> p.<font color='#BB00BB'>x</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>-</font> left;
            <font color='#0000FF'>const</font> <font color='#0000FF'><u>double</u></font> tb_frac <font color='#5555FF'>=</font> p.<font color='#BB00BB'>y</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>-</font> top;

            <font color='#0000FF'><u>double</u></font> tl <font color='#5555FF'>=</font> <font color='#979000'>0</font>, tr <font color='#5555FF'>=</font> <font color='#979000'>0</font>, bl <font color='#5555FF'>=</font> <font color='#979000'>0</font>, br <font color='#5555FF'>=</font> <font color='#979000'>0</font>;

            <font color='#BB00BB'>assign_pixel</font><font face='Lucida Console'>(</font>tl, img[top][left]<font face='Lucida Console'>)</font>;
            <font color='#BB00BB'>assign_pixel</font><font face='Lucida Console'>(</font>tr, img[top][right]<font face='Lucida Console'>)</font>;
            <font color='#BB00BB'>assign_pixel</font><font face='Lucida Console'>(</font>bl, img[bottom][left]<font face='Lucida Console'>)</font>;
            <font color='#BB00BB'>assign_pixel</font><font face='Lucida Console'>(</font>br, img[bottom][right]<font face='Lucida Console'>)</font>;
            
            <font color='#0000FF'><u>double</u></font> temp <font color='#5555FF'>=</font> <font face='Lucida Console'>(</font><font color='#979000'>1</font><font color='#5555FF'>-</font>tb_frac<font face='Lucida Console'>)</font><font color='#5555FF'>*</font><font face='Lucida Console'>(</font><font face='Lucida Console'>(</font><font color='#979000'>1</font><font color='#5555FF'>-</font>lr_frac<font face='Lucida Console'>)</font><font color='#5555FF'>*</font>tl <font color='#5555FF'>+</font> lr_frac<font color='#5555FF'>*</font>tr<font face='Lucida Console'>)</font> <font color='#5555FF'>+</font> 
                              tb_frac<font color='#5555FF'>*</font><font face='Lucida Console'>(</font><font face='Lucida Console'>(</font><font color='#979000'>1</font><font color='#5555FF'>-</font>lr_frac<font face='Lucida Console'>)</font><font color='#5555FF'>*</font>bl <font color='#5555FF'>+</font> lr_frac<font color='#5555FF'>*</font>br<font face='Lucida Console'>)</font>;
                            
            <font color='#BB00BB'>assign_pixel</font><font face='Lucida Console'>(</font>result, temp<font face='Lucida Console'>)</font>;
            <font color='#0000FF'>return</font> <font color='#979000'>true</font>;
        <b>}</b>

        <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font><font color='#0000FF'>typename</font> T, <font color='#0000FF'>typename</font> image_view_type, <font color='#0000FF'>typename</font> pixel_type<font color='#5555FF'>&gt;</font>
        <font color='#0000FF'>typename</font> enable_if<font color='#5555FF'>&lt;</font>is_rgb_image<font color='#5555FF'>&lt;</font>image_view_type<font color='#5555FF'>&gt;</font>,<font color='#0000FF'><u>bool</u></font><font color='#5555FF'>&gt;</font>::type <b><a name='operator'></a>operator</b><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font face='Lucida Console'>(</font>
            <font color='#0000FF'>const</font> image_view_type<font color='#5555FF'>&amp;</font> img,
            <font color='#0000FF'>const</font> dlib::vector<font color='#5555FF'>&lt;</font>T,<font color='#979000'>2</font><font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> p,
            pixel_type<font color='#5555FF'>&amp;</font> result
        <font face='Lucida Console'>)</font> <font color='#0000FF'>const</font>
        <b>{</b>
            <font color='#BB00BB'>COMPILE_TIME_ASSERT</font><font face='Lucida Console'>(</font>pixel_traits<font color='#5555FF'>&lt;</font><font color='#0000FF'>typename</font> image_view_type::pixel_type<font color='#5555FF'>&gt;</font>::has_alpha <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>false</font><font face='Lucida Console'>)</font>;

            <font color='#0000FF'>const</font> <font color='#0000FF'><u>long</u></font> left   <font color='#5555FF'>=</font> <font color='#0000FF'>static_cast</font><font color='#5555FF'>&lt;</font><font color='#0000FF'><u>long</u></font><font color='#5555FF'>&gt;</font><font face='Lucida Console'>(</font>std::<font color='#BB00BB'>floor</font><font face='Lucida Console'>(</font>p.<font color='#BB00BB'>x</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
            <font color='#0000FF'>const</font> <font color='#0000FF'><u>long</u></font> top    <font color='#5555FF'>=</font> <font color='#0000FF'>static_cast</font><font color='#5555FF'>&lt;</font><font color='#0000FF'><u>long</u></font><font color='#5555FF'>&gt;</font><font face='Lucida Console'>(</font>std::<font color='#BB00BB'>floor</font><font face='Lucida Console'>(</font>p.<font color='#BB00BB'>y</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
            <font color='#0000FF'>const</font> <font color='#0000FF'><u>long</u></font> right  <font color='#5555FF'>=</font> left<font color='#5555FF'>+</font><font color='#979000'>1</font>;
            <font color='#0000FF'>const</font> <font color='#0000FF'><u>long</u></font> bottom <font color='#5555FF'>=</font> top<font color='#5555FF'>+</font><font color='#979000'>1</font>;


            <font color='#009900'>// if the interpolation goes outside img 
</font>            <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font><font color='#5555FF'>!</font><font face='Lucida Console'>(</font>left <font color='#5555FF'>&gt;</font><font color='#5555FF'>=</font> <font color='#979000'>0</font> <font color='#5555FF'>&amp;</font><font color='#5555FF'>&amp;</font> top <font color='#5555FF'>&gt;</font><font color='#5555FF'>=</font> <font color='#979000'>0</font> <font color='#5555FF'>&amp;</font><font color='#5555FF'>&amp;</font> right <font color='#5555FF'>&lt;</font> img.<font color='#BB00BB'>nc</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>&amp;</font><font color='#5555FF'>&amp;</font> bottom <font color='#5555FF'>&lt;</font> img.<font color='#BB00BB'>nr</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>
                <font color='#0000FF'>return</font> <font color='#979000'>false</font>;

            <font color='#0000FF'>const</font> <font color='#0000FF'><u>double</u></font> lr_frac <font color='#5555FF'>=</font> p.<font color='#BB00BB'>x</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>-</font> left;
            <font color='#0000FF'>const</font> <font color='#0000FF'><u>double</u></font> tb_frac <font color='#5555FF'>=</font> p.<font color='#BB00BB'>y</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>-</font> top;

            <font color='#0000FF'><u>double</u></font> tl, tr, bl, br;

            tl <font color='#5555FF'>=</font> img[top][left].red;
            tr <font color='#5555FF'>=</font> img[top][right].red;
            bl <font color='#5555FF'>=</font> img[bottom][left].red;
            br <font color='#5555FF'>=</font> img[bottom][right].red;
            <font color='#0000FF'>const</font> <font color='#0000FF'><u>double</u></font> red <font color='#5555FF'>=</font> <font face='Lucida Console'>(</font><font color='#979000'>1</font><font color='#5555FF'>-</font>tb_frac<font face='Lucida Console'>)</font><font color='#5555FF'>*</font><font face='Lucida Console'>(</font><font face='Lucida Console'>(</font><font color='#979000'>1</font><font color='#5555FF'>-</font>lr_frac<font face='Lucida Console'>)</font><font color='#5555FF'>*</font>tl <font color='#5555FF'>+</font> lr_frac<font color='#5555FF'>*</font>tr<font face='Lucida Console'>)</font> <font color='#5555FF'>+</font> 
                                   tb_frac<font color='#5555FF'>*</font><font face='Lucida Console'>(</font><font face='Lucida Console'>(</font><font color='#979000'>1</font><font color='#5555FF'>-</font>lr_frac<font face='Lucida Console'>)</font><font color='#5555FF'>*</font>bl <font color='#5555FF'>+</font> lr_frac<font color='#5555FF'>*</font>br<font face='Lucida Console'>)</font>;

            tl <font color='#5555FF'>=</font> img[top][left].green;
            tr <font color='#5555FF'>=</font> img[top][right].green;
            bl <font color='#5555FF'>=</font> img[bottom][left].green;
            br <font color='#5555FF'>=</font> img[bottom][right].green;
            <font color='#0000FF'>const</font> <font color='#0000FF'><u>double</u></font> green <font color='#5555FF'>=</font> <font face='Lucida Console'>(</font><font color='#979000'>1</font><font color='#5555FF'>-</font>tb_frac<font face='Lucida Console'>)</font><font color='#5555FF'>*</font><font face='Lucida Console'>(</font><font face='Lucida Console'>(</font><font color='#979000'>1</font><font color='#5555FF'>-</font>lr_frac<font face='Lucida Console'>)</font><font color='#5555FF'>*</font>tl <font color='#5555FF'>+</font> lr_frac<font color='#5555FF'>*</font>tr<font face='Lucida Console'>)</font> <font color='#5555FF'>+</font> 
                                   tb_frac<font color='#5555FF'>*</font><font face='Lucida Console'>(</font><font face='Lucida Console'>(</font><font color='#979000'>1</font><font color='#5555FF'>-</font>lr_frac<font face='Lucida Console'>)</font><font color='#5555FF'>*</font>bl <font color='#5555FF'>+</font> lr_frac<font color='#5555FF'>*</font>br<font face='Lucida Console'>)</font>;

            tl <font color='#5555FF'>=</font> img[top][left].blue;
            tr <font color='#5555FF'>=</font> img[top][right].blue;
            bl <font color='#5555FF'>=</font> img[bottom][left].blue;
            br <font color='#5555FF'>=</font> img[bottom][right].blue;
            <font color='#0000FF'>const</font> <font color='#0000FF'><u>double</u></font> blue <font color='#5555FF'>=</font> <font face='Lucida Console'>(</font><font color='#979000'>1</font><font color='#5555FF'>-</font>tb_frac<font face='Lucida Console'>)</font><font color='#5555FF'>*</font><font face='Lucida Console'>(</font><font face='Lucida Console'>(</font><font color='#979000'>1</font><font color='#5555FF'>-</font>lr_frac<font face='Lucida Console'>)</font><font color='#5555FF'>*</font>tl <font color='#5555FF'>+</font> lr_frac<font color='#5555FF'>*</font>tr<font face='Lucida Console'>)</font> <font color='#5555FF'>+</font> 
                                   tb_frac<font color='#5555FF'>*</font><font face='Lucida Console'>(</font><font face='Lucida Console'>(</font><font color='#979000'>1</font><font color='#5555FF'>-</font>lr_frac<font face='Lucida Console'>)</font><font color='#5555FF'>*</font>bl <font color='#5555FF'>+</font> lr_frac<font color='#5555FF'>*</font>br<font face='Lucida Console'>)</font>;
                            
            rgb_pixel temp;
            <font color='#BB00BB'>assign_pixel</font><font face='Lucida Console'>(</font>temp.red, red<font face='Lucida Console'>)</font>;
            <font color='#BB00BB'>assign_pixel</font><font face='Lucida Console'>(</font>temp.green, green<font face='Lucida Console'>)</font>;
            <font color='#BB00BB'>assign_pixel</font><font face='Lucida Console'>(</font>temp.blue, blue<font face='Lucida Console'>)</font>;
            <font color='#BB00BB'>assign_pixel</font><font face='Lucida Console'>(</font>result, temp<font face='Lucida Console'>)</font>;
            <font color='#0000FF'>return</font> <font color='#979000'>true</font>;
        <b>}</b>
    <b>}</b>;

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
    <font color='#0000FF'>class</font> <b><a name='interpolate_quadratic'></a>interpolate_quadratic</b>
    <b>{</b>
        <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font><font color='#0000FF'>typename</font> T<font color='#5555FF'>&gt;</font>
        <font color='#0000FF'>struct</font> <b><a name='is_rgb_image'></a>is_rgb_image</b> 
        <b>{</b>
            <font color='#0000FF'>const</font> <font color='#0000FF'>static</font> <font color='#0000FF'><u>bool</u></font> value <font color='#5555FF'>=</font> pixel_traits<font color='#5555FF'>&lt;</font><font color='#0000FF'>typename</font> T::pixel_type<font color='#5555FF'>&gt;</font>::rgb;
        <b>}</b>;

    <font color='#0000FF'>public</font>:

        <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font><font color='#0000FF'>typename</font> T, <font color='#0000FF'>typename</font> image_view_type, <font color='#0000FF'>typename</font> pixel_type<font color='#5555FF'>&gt;</font>
        <font color='#0000FF'>typename</font> disable_if<font color='#5555FF'>&lt;</font>is_rgb_image<font color='#5555FF'>&lt;</font>image_view_type<font color='#5555FF'>&gt;</font>,<font color='#0000FF'><u>bool</u></font><font color='#5555FF'>&gt;</font>::type <b><a name='operator'></a>operator</b><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font face='Lucida Console'>(</font>
            <font color='#0000FF'>const</font> image_view_type<font color='#5555FF'>&amp;</font> img,
            <font color='#0000FF'>const</font> dlib::vector<font color='#5555FF'>&lt;</font>T,<font color='#979000'>2</font><font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> p,
            pixel_type<font color='#5555FF'>&amp;</font> result
        <font face='Lucida Console'>)</font> <font color='#0000FF'>const</font>
        <b>{</b>
            <font color='#BB00BB'>COMPILE_TIME_ASSERT</font><font face='Lucida Console'>(</font>pixel_traits<font color='#5555FF'>&lt;</font><font color='#0000FF'>typename</font> image_view_type::pixel_type<font color='#5555FF'>&gt;</font>::has_alpha <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>false</font><font face='Lucida Console'>)</font>;

            <font color='#0000FF'>const</font> point <font color='#BB00BB'>pp</font><font face='Lucida Console'>(</font>p<font face='Lucida Console'>)</font>;

            <font color='#009900'>// if the interpolation goes outside img 
</font>            <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font><font color='#5555FF'>!</font><font color='#BB00BB'>get_rect</font><font face='Lucida Console'>(</font>img<font face='Lucida Console'>)</font>.<font color='#BB00BB'>contains</font><font face='Lucida Console'>(</font><font color='#BB00BB'>grow_rect</font><font face='Lucida Console'>(</font>pp,<font color='#979000'>1</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font> 
                <font color='#0000FF'>return</font> <font color='#979000'>false</font>;

            <font color='#0000FF'>const</font> <font color='#0000FF'><u>long</u></font> r <font color='#5555FF'>=</font> pp.<font color='#BB00BB'>y</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;
            <font color='#0000FF'>const</font> <font color='#0000FF'><u>long</u></font> c <font color='#5555FF'>=</font> pp.<font color='#BB00BB'>x</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;

            <font color='#0000FF'>const</font> <font color='#0000FF'><u>double</u></font> temp <font color='#5555FF'>=</font> <font color='#BB00BB'>interpolate</font><font face='Lucida Console'>(</font>p<font color='#5555FF'>-</font>pp, 
                                    img[r<font color='#5555FF'>-</font><font color='#979000'>1</font>][c<font color='#5555FF'>-</font><font color='#979000'>1</font>],
                                    img[r<font color='#5555FF'>-</font><font color='#979000'>1</font>][c  ],
                                    img[r<font color='#5555FF'>-</font><font color='#979000'>1</font>][c<font color='#5555FF'>+</font><font color='#979000'>1</font>],
                                    img[r  ][c<font color='#5555FF'>-</font><font color='#979000'>1</font>],
                                    img[r  ][c  ],
                                    img[r  ][c<font color='#5555FF'>+</font><font color='#979000'>1</font>],
                                    img[r<font color='#5555FF'>+</font><font color='#979000'>1</font>][c<font color='#5555FF'>-</font><font color='#979000'>1</font>],
                                    img[r<font color='#5555FF'>+</font><font color='#979000'>1</font>][c  ],
                                    img[r<font color='#5555FF'>+</font><font color='#979000'>1</font>][c<font color='#5555FF'>+</font><font color='#979000'>1</font>]<font face='Lucida Console'>)</font>;

            <font color='#BB00BB'>assign_pixel</font><font face='Lucida Console'>(</font>result, temp<font face='Lucida Console'>)</font>;
            <font color='#0000FF'>return</font> <font color='#979000'>true</font>;
        <b>}</b>

        <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font><font color='#0000FF'>typename</font> T, <font color='#0000FF'>typename</font> image_view_type, <font color='#0000FF'>typename</font> pixel_type<font color='#5555FF'>&gt;</font>
        <font color='#0000FF'>typename</font> enable_if<font color='#5555FF'>&lt;</font>is_rgb_image<font color='#5555FF'>&lt;</font>image_view_type<font color='#5555FF'>&gt;</font>,<font color='#0000FF'><u>bool</u></font><font color='#5555FF'>&gt;</font>::type <b><a name='operator'></a>operator</b><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font face='Lucida Console'>(</font>
            <font color='#0000FF'>const</font> image_view_type<font color='#5555FF'>&amp;</font> img,
            <font color='#0000FF'>const</font> dlib::vector<font color='#5555FF'>&lt;</font>T,<font color='#979000'>2</font><font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> p,
            pixel_type<font color='#5555FF'>&amp;</font> result
        <font face='Lucida Console'>)</font> <font color='#0000FF'>const</font>
        <b>{</b>
            <font color='#BB00BB'>COMPILE_TIME_ASSERT</font><font face='Lucida Console'>(</font>pixel_traits<font color='#5555FF'>&lt;</font><font color='#0000FF'>typename</font> image_view_type::pixel_type<font color='#5555FF'>&gt;</font>::has_alpha <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>false</font><font face='Lucida Console'>)</font>;

            <font color='#0000FF'>const</font> point <font color='#BB00BB'>pp</font><font face='Lucida Console'>(</font>p<font face='Lucida Console'>)</font>;

            <font color='#009900'>// if the interpolation goes outside img 
</font>            <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font><font color='#5555FF'>!</font><font color='#BB00BB'>get_rect</font><font face='Lucida Console'>(</font>img<font face='Lucida Console'>)</font>.<font color='#BB00BB'>contains</font><font face='Lucida Console'>(</font><font color='#BB00BB'>grow_rect</font><font face='Lucida Console'>(</font>pp,<font color='#979000'>1</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font> 
                <font color='#0000FF'>return</font> <font color='#979000'>false</font>;

            <font color='#0000FF'>const</font> <font color='#0000FF'><u>long</u></font> r <font color='#5555FF'>=</font> pp.<font color='#BB00BB'>y</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;
            <font color='#0000FF'>const</font> <font color='#0000FF'><u>long</u></font> c <font color='#5555FF'>=</font> pp.<font color='#BB00BB'>x</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;

            <font color='#0000FF'>const</font> <font color='#0000FF'><u>double</u></font> red <font color='#5555FF'>=</font> <font color='#BB00BB'>interpolate</font><font face='Lucida Console'>(</font>p<font color='#5555FF'>-</font>pp, 
                            img[r<font color='#5555FF'>-</font><font color='#979000'>1</font>][c<font color='#5555FF'>-</font><font color='#979000'>1</font>].red,
                            img[r<font color='#5555FF'>-</font><font color='#979000'>1</font>][c  ].red,
                            img[r<font color='#5555FF'>-</font><font color='#979000'>1</font>][c<font color='#5555FF'>+</font><font color='#979000'>1</font>].red,
                            img[r  ][c<font color='#5555FF'>-</font><font color='#979000'>1</font>].red,
                            img[r  ][c  ].red,
                            img[r  ][c<font color='#5555FF'>+</font><font color='#979000'>1</font>].red,
                            img[r<font color='#5555FF'>+</font><font color='#979000'>1</font>][c<font color='#5555FF'>-</font><font color='#979000'>1</font>].red,
                            img[r<font color='#5555FF'>+</font><font color='#979000'>1</font>][c  ].red,
                            img[r<font color='#5555FF'>+</font><font color='#979000'>1</font>][c<font color='#5555FF'>+</font><font color='#979000'>1</font>].red<font face='Lucida Console'>)</font>;
            <font color='#0000FF'>const</font> <font color='#0000FF'><u>double</u></font> green <font color='#5555FF'>=</font> <font color='#BB00BB'>interpolate</font><font face='Lucida Console'>(</font>p<font color='#5555FF'>-</font>pp, 
                            img[r<font color='#5555FF'>-</font><font color='#979000'>1</font>][c<font color='#5555FF'>-</font><font color='#979000'>1</font>].green,
                            img[r<font color='#5555FF'>-</font><font color='#979000'>1</font>][c  ].green,
                            img[r<font color='#5555FF'>-</font><font color='#979000'>1</font>][c<font color='#5555FF'>+</font><font color='#979000'>1</font>].green,
                            img[r  ][c<font color='#5555FF'>-</font><font color='#979000'>1</font>].green,
                            img[r  ][c  ].green,
                            img[r  ][c<font color='#5555FF'>+</font><font color='#979000'>1</font>].green,
                            img[r<font color='#5555FF'>+</font><font color='#979000'>1</font>][c<font color='#5555FF'>-</font><font color='#979000'>1</font>].green,
                            img[r<font color='#5555FF'>+</font><font color='#979000'>1</font>][c  ].green,
                            img[r<font color='#5555FF'>+</font><font color='#979000'>1</font>][c<font color='#5555FF'>+</font><font color='#979000'>1</font>].green<font face='Lucida Console'>)</font>;
            <font color='#0000FF'>const</font> <font color='#0000FF'><u>double</u></font> blue <font color='#5555FF'>=</font> <font color='#BB00BB'>interpolate</font><font face='Lucida Console'>(</font>p<font color='#5555FF'>-</font>pp, 
                            img[r<font color='#5555FF'>-</font><font color='#979000'>1</font>][c<font color='#5555FF'>-</font><font color='#979000'>1</font>].blue,
                            img[r<font color='#5555FF'>-</font><font color='#979000'>1</font>][c  ].blue,
                            img[r<font color='#5555FF'>-</font><font color='#979000'>1</font>][c<font color='#5555FF'>+</font><font color='#979000'>1</font>].blue,
                            img[r  ][c<font color='#5555FF'>-</font><font color='#979000'>1</font>].blue,
                            img[r  ][c  ].blue,
                            img[r  ][c<font color='#5555FF'>+</font><font color='#979000'>1</font>].blue,
                            img[r<font color='#5555FF'>+</font><font color='#979000'>1</font>][c<font color='#5555FF'>-</font><font color='#979000'>1</font>].blue,
                            img[r<font color='#5555FF'>+</font><font color='#979000'>1</font>][c  ].blue,
                            img[r<font color='#5555FF'>+</font><font color='#979000'>1</font>][c<font color='#5555FF'>+</font><font color='#979000'>1</font>].blue<font face='Lucida Console'>)</font>;


            rgb_pixel temp;
            <font color='#BB00BB'>assign_pixel</font><font face='Lucida Console'>(</font>temp.red, red<font face='Lucida Console'>)</font>;
            <font color='#BB00BB'>assign_pixel</font><font face='Lucida Console'>(</font>temp.green, green<font face='Lucida Console'>)</font>;
            <font color='#BB00BB'>assign_pixel</font><font face='Lucida Console'>(</font>temp.blue, blue<font face='Lucida Console'>)</font>;
            <font color='#BB00BB'>assign_pixel</font><font face='Lucida Console'>(</font>result, temp<font face='Lucida Console'>)</font>;

            <font color='#0000FF'>return</font> <font color='#979000'>true</font>;
        <b>}</b>

    <font color='#0000FF'>private</font>:

        <font color='#009900'>/*  tl tm tr
            ml mm mr
            bl bm br
        */</font>
        <font color='#009900'>// The above is the pixel layout in our little 3x3 neighborhood.  interpolate() will 
</font>        <font color='#009900'>// fit a quadratic to these 9 pixels and then use that quadratic to find the interpolated 
</font>        <font color='#009900'>// value at point p.
</font>        <font color='#0000FF'>inline</font> <font color='#0000FF'><u>double</u></font> <b><a name='interpolate'></a>interpolate</b><font face='Lucida Console'>(</font>
            <font color='#0000FF'>const</font> dlib::vector<font color='#5555FF'>&lt;</font><font color='#0000FF'><u>double</u></font>,<font color='#979000'>2</font><font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> p,
            <font color='#0000FF'><u>double</u></font> tl, <font color='#0000FF'><u>double</u></font> tm, <font color='#0000FF'><u>double</u></font> tr, 
            <font color='#0000FF'><u>double</u></font> ml, <font color='#0000FF'><u>double</u></font> mm, <font color='#0000FF'><u>double</u></font> mr, 
            <font color='#0000FF'><u>double</u></font> bl, <font color='#0000FF'><u>double</u></font> bm, <font color='#0000FF'><u>double</u></font> br
        <font face='Lucida Console'>)</font> <font color='#0000FF'>const</font>
        <b>{</b>
            matrix<font color='#5555FF'>&lt;</font><font color='#0000FF'><u>double</u></font>,<font color='#979000'>6</font>,<font color='#979000'>1</font><font color='#5555FF'>&gt;</font> w;
            <font color='#009900'>// x
</font>            <font color='#BB00BB'>w</font><font face='Lucida Console'>(</font><font color='#979000'>0</font><font face='Lucida Console'>)</font> <font color='#5555FF'>=</font> <font face='Lucida Console'>(</font>tr <font color='#5555FF'>+</font> mr <font color='#5555FF'>+</font> br <font color='#5555FF'>-</font> tl <font color='#5555FF'>-</font> ml <font color='#5555FF'>-</font> bl<font face='Lucida Console'>)</font><font color='#5555FF'>*</font><font color='#979000'>0.16666666666</font>;
            <font color='#009900'>// y
</font>            <font color='#BB00BB'>w</font><font face='Lucida Console'>(</font><font color='#979000'>1</font><font face='Lucida Console'>)</font> <font color='#5555FF'>=</font> <font face='Lucida Console'>(</font>bl <font color='#5555FF'>+</font> bm <font color='#5555FF'>+</font> br <font color='#5555FF'>-</font> tl <font color='#5555FF'>-</font> tm <font color='#5555FF'>-</font> tr<font face='Lucida Console'>)</font><font color='#5555FF'>*</font><font color='#979000'>0.16666666666</font>;
            <font color='#009900'>// x^2
</font>            <font color='#BB00BB'>w</font><font face='Lucida Console'>(</font><font color='#979000'>2</font><font face='Lucida Console'>)</font> <font color='#5555FF'>=</font> <font face='Lucida Console'>(</font>tl <font color='#5555FF'>+</font> tr <font color='#5555FF'>+</font> ml <font color='#5555FF'>+</font> mr <font color='#5555FF'>+</font> bl <font color='#5555FF'>+</font> br<font face='Lucida Console'>)</font><font color='#5555FF'>*</font><font color='#979000'>0.16666666666</font> <font color='#5555FF'>-</font> <font face='Lucida Console'>(</font>tm <font color='#5555FF'>+</font> mm <font color='#5555FF'>+</font> bm<font face='Lucida Console'>)</font><font color='#5555FF'>*</font><font color='#979000'>0.333333333</font>;
            <font color='#009900'>// x*y
</font>            <font color='#BB00BB'>w</font><font face='Lucida Console'>(</font><font color='#979000'>3</font><font face='Lucida Console'>)</font> <font color='#5555FF'>=</font> <font face='Lucida Console'>(</font>tl <font color='#5555FF'>-</font> tr <font color='#5555FF'>-</font> bl <font color='#5555FF'>+</font> br<font face='Lucida Console'>)</font><font color='#5555FF'>*</font><font color='#979000'>0.25</font>;
            <font color='#009900'>// y^2
</font>            <font color='#BB00BB'>w</font><font face='Lucida Console'>(</font><font color='#979000'>4</font><font face='Lucida Console'>)</font> <font color='#5555FF'>=</font> <font face='Lucida Console'>(</font>tl <font color='#5555FF'>+</font> tm <font color='#5555FF'>+</font> tr <font color='#5555FF'>+</font> bl <font color='#5555FF'>+</font> bm <font color='#5555FF'>+</font> br<font face='Lucida Console'>)</font><font color='#5555FF'>*</font><font color='#979000'>0.16666666666</font> <font color='#5555FF'>-</font> <font face='Lucida Console'>(</font>ml <font color='#5555FF'>+</font> mm <font color='#5555FF'>+</font> mr<font face='Lucida Console'>)</font><font color='#5555FF'>*</font><font color='#979000'>0.333333333</font>;
            <font color='#009900'>// 1 (constant term)
</font>            <font color='#BB00BB'>w</font><font face='Lucida Console'>(</font><font color='#979000'>5</font><font face='Lucida Console'>)</font> <font color='#5555FF'>=</font> <font face='Lucida Console'>(</font>tm <font color='#5555FF'>+</font> ml <font color='#5555FF'>+</font> mr <font color='#5555FF'>+</font> bm<font face='Lucida Console'>)</font><font color='#5555FF'>*</font><font color='#979000'>0.222222222</font> <font color='#5555FF'>-</font> <font face='Lucida Console'>(</font>tl <font color='#5555FF'>+</font> tr <font color='#5555FF'>+</font> bl <font color='#5555FF'>+</font> br<font face='Lucida Console'>)</font><font color='#5555FF'>*</font><font color='#979000'>0.11111111</font> <font color='#5555FF'>+</font> <font face='Lucida Console'>(</font>mm<font face='Lucida Console'>)</font><font color='#5555FF'>*</font><font color='#979000'>0.55555556</font>;

            <font color='#0000FF'>const</font> <font color='#0000FF'><u>double</u></font> x <font color='#5555FF'>=</font> p.<font color='#BB00BB'>x</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;
            <font color='#0000FF'>const</font> <font color='#0000FF'><u>double</u></font> y <font color='#5555FF'>=</font> p.<font color='#BB00BB'>y</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;

            matrix<font color='#5555FF'>&lt;</font><font color='#0000FF'><u>double</u></font>,<font color='#979000'>6</font>,<font color='#979000'>1</font><font color='#5555FF'>&gt;</font> z;
            z <font color='#5555FF'>=</font> x, y, x<font color='#5555FF'>*</font>x, x<font color='#5555FF'>*</font>y, y<font color='#5555FF'>*</font>y, <font color='#979000'>1.0</font>;
                            
            <font color='#0000FF'>return</font> <font color='#BB00BB'>dot</font><font face='Lucida Console'>(</font>w,z<font face='Lucida Console'>)</font>;
        <b>}</b>
    <b>}</b>;

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font><font color='#009900'>// ----------------------------------------------------------------------------------------
</font><font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
    <font color='#0000FF'>class</font> <b><a name='black_background'></a>black_background</b>
    <b>{</b>
    <font color='#0000FF'>public</font>:
        <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font><font color='#0000FF'>typename</font> pixel_type<font color='#5555FF'>&gt;</font>
        <font color='#0000FF'><u>void</u></font> <b><a name='operator'></a>operator</b><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font face='Lucida Console'>(</font> pixel_type<font color='#5555FF'>&amp;</font> p<font face='Lucida Console'>)</font> <font color='#0000FF'>const</font> <b>{</b> <font color='#BB00BB'>assign_pixel</font><font face='Lucida Console'>(</font>p, <font color='#979000'>0</font><font face='Lucida Console'>)</font>; <b>}</b>
    <b>}</b>;

    <font color='#0000FF'>class</font> <b><a name='white_background'></a>white_background</b>
    <b>{</b>
    <font color='#0000FF'>public</font>:
        <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font><font color='#0000FF'>typename</font> pixel_type<font color='#5555FF'>&gt;</font>
        <font color='#0000FF'><u>void</u></font> <b><a name='operator'></a>operator</b><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font face='Lucida Console'>(</font> pixel_type<font color='#5555FF'>&amp;</font> p<font face='Lucida Console'>)</font> <font color='#0000FF'>const</font> <b>{</b> <font color='#BB00BB'>assign_pixel</font><font face='Lucida Console'>(</font>p, <font color='#979000'>255</font><font face='Lucida Console'>)</font>; <b>}</b>
    <b>}</b>;

    <font color='#0000FF'>class</font> <b><a name='no_background'></a>no_background</b>
    <b>{</b>
    <font color='#0000FF'>public</font>:
        <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font><font color='#0000FF'>typename</font> pixel_type<font color='#5555FF'>&gt;</font>
        <font color='#0000FF'><u>void</u></font> <b><a name='operator'></a>operator</b><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font face='Lucida Console'>(</font> pixel_type<font color='#5555FF'>&amp;</font> <font face='Lucida Console'>)</font> <font color='#0000FF'>const</font> <b>{</b> <b>}</b>
    <b>}</b>;

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font>
        <font color='#0000FF'>typename</font> image_type1,
        <font color='#0000FF'>typename</font> image_type2,
        <font color='#0000FF'>typename</font> interpolation_type,
        <font color='#0000FF'>typename</font> point_mapping_type,
        <font color='#0000FF'>typename</font> background_type
        <font color='#5555FF'>&gt;</font>
    <font color='#0000FF'><u>void</u></font> <b><a name='transform_image'></a>transform_image</b> <font face='Lucida Console'>(</font>
        <font color='#0000FF'>const</font> image_type1<font color='#5555FF'>&amp;</font> in_img,
        image_type2<font color='#5555FF'>&amp;</font> out_img,
        <font color='#0000FF'>const</font> interpolation_type<font color='#5555FF'>&amp;</font> interp,
        <font color='#0000FF'>const</font> point_mapping_type<font color='#5555FF'>&amp;</font> map_point,
        <font color='#0000FF'>const</font> background_type<font color='#5555FF'>&amp;</font> set_background,
        <font color='#0000FF'>const</font> rectangle<font color='#5555FF'>&amp;</font> area
    <font face='Lucida Console'>)</font>
    <b>{</b>
        <font color='#009900'>// make sure requires clause is not broken
</font>        <font color='#BB00BB'>DLIB_ASSERT</font><font face='Lucida Console'>(</font> <font color='#BB00BB'>get_rect</font><font face='Lucida Console'>(</font>out_img<font face='Lucida Console'>)</font>.<font color='#BB00BB'>contains</font><font face='Lucida Console'>(</font>area<font face='Lucida Console'>)</font> <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>true</font> <font color='#5555FF'>&amp;</font><font color='#5555FF'>&amp;</font>
                     <font color='#BB00BB'>is_same_object</font><font face='Lucida Console'>(</font>in_img, out_img<font face='Lucida Console'>)</font> <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>false</font> ,
            "<font color='#CC0000'>\t void transform_image()</font>"
            <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t Invalid inputs were given to this function.</font>"
            <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t get_rect(out_img).contains(area): </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> <font color='#BB00BB'>get_rect</font><font face='Lucida Console'>(</font>out_img<font face='Lucida Console'>)</font>.<font color='#BB00BB'>contains</font><font face='Lucida Console'>(</font>area<font face='Lucida Console'>)</font>
            <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t get_rect(out_img): </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> <font color='#BB00BB'>get_rect</font><font face='Lucida Console'>(</font>out_img<font face='Lucida Console'>)</font>
            <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t area:              </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> area
            <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t is_same_object(in_img, out_img):  </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> <font color='#BB00BB'>is_same_object</font><font face='Lucida Console'>(</font>in_img, out_img<font face='Lucida Console'>)</font>
            <font face='Lucida Console'>)</font>;

        const_image_view<font color='#5555FF'>&lt;</font>image_type1<font color='#5555FF'>&gt;</font> <font color='#BB00BB'>imgv</font><font face='Lucida Console'>(</font>in_img<font face='Lucida Console'>)</font>;
        image_view<font color='#5555FF'>&lt;</font>image_type2<font color='#5555FF'>&gt;</font> <font color='#BB00BB'>out_imgv</font><font face='Lucida Console'>(</font>out_img<font face='Lucida Console'>)</font>;

        <font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>long</u></font> r <font color='#5555FF'>=</font> area.<font color='#BB00BB'>top</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>; r <font color='#5555FF'>&lt;</font><font color='#5555FF'>=</font> area.<font color='#BB00BB'>bottom</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>; <font color='#5555FF'>+</font><font color='#5555FF'>+</font>r<font face='Lucida Console'>)</font>
        <b>{</b>
            <font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>long</u></font> c <font color='#5555FF'>=</font> area.<font color='#BB00BB'>left</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>; c <font color='#5555FF'>&lt;</font><font color='#5555FF'>=</font> area.<font color='#BB00BB'>right</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>; <font color='#5555FF'>+</font><font color='#5555FF'>+</font>c<font face='Lucida Console'>)</font>
            <b>{</b>
                <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font><font color='#5555FF'>!</font><font color='#BB00BB'>interp</font><font face='Lucida Console'>(</font>imgv, <font color='#BB00BB'>map_point</font><font face='Lucida Console'>(</font>dlib::vector<font color='#5555FF'>&lt;</font><font color='#0000FF'><u>double</u></font>,<font color='#979000'>2</font><font color='#5555FF'>&gt;</font><font face='Lucida Console'>(</font>c,r<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>, out_imgv[r][c]<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>
                    <font color='#BB00BB'>set_background</font><font face='Lucida Console'>(</font>out_imgv[r][c]<font face='Lucida Console'>)</font>;
            <b>}</b>
        <b>}</b>
    <b>}</b>

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font>
        <font color='#0000FF'>typename</font> image_type1,
        <font color='#0000FF'>typename</font> image_type2,
        <font color='#0000FF'>typename</font> interpolation_type,
        <font color='#0000FF'>typename</font> point_mapping_type,
        <font color='#0000FF'>typename</font> background_type
        <font color='#5555FF'>&gt;</font>
    <font color='#0000FF'><u>void</u></font> <b><a name='transform_image'></a>transform_image</b> <font face='Lucida Console'>(</font>
        <font color='#0000FF'>const</font> image_type1<font color='#5555FF'>&amp;</font> in_img,
        image_type2<font color='#5555FF'>&amp;</font> out_img,
        <font color='#0000FF'>const</font> interpolation_type<font color='#5555FF'>&amp;</font> interp,
        <font color='#0000FF'>const</font> point_mapping_type<font color='#5555FF'>&amp;</font> map_point,
        <font color='#0000FF'>const</font> background_type<font color='#5555FF'>&amp;</font> set_background
    <font face='Lucida Console'>)</font>
    <b>{</b>
        <font color='#009900'>// make sure requires clause is not broken
</font>        <font color='#BB00BB'>DLIB_ASSERT</font><font face='Lucida Console'>(</font> <font color='#BB00BB'>is_same_object</font><font face='Lucida Console'>(</font>in_img, out_img<font face='Lucida Console'>)</font> <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>false</font> ,
            "<font color='#CC0000'>\t void transform_image()</font>"
            <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t Invalid inputs were given to this function.</font>"
            <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t is_same_object(in_img, out_img):  </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> <font color='#BB00BB'>is_same_object</font><font face='Lucida Console'>(</font>in_img, out_img<font face='Lucida Console'>)</font>
            <font face='Lucida Console'>)</font>;

        <font color='#BB00BB'>transform_image</font><font face='Lucida Console'>(</font>in_img, out_img, interp, map_point, set_background, <font color='#BB00BB'>get_rect</font><font face='Lucida Console'>(</font>out_img<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
    <b>}</b>

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font>
        <font color='#0000FF'>typename</font> image_type1,
        <font color='#0000FF'>typename</font> image_type2,
        <font color='#0000FF'>typename</font> interpolation_type,
        <font color='#0000FF'>typename</font> point_mapping_type
        <font color='#5555FF'>&gt;</font>
    <font color='#0000FF'><u>void</u></font> <b><a name='transform_image'></a>transform_image</b> <font face='Lucida Console'>(</font>
        <font color='#0000FF'>const</font> image_type1<font color='#5555FF'>&amp;</font> in_img,
        image_type2<font color='#5555FF'>&amp;</font> out_img,
        <font color='#0000FF'>const</font> interpolation_type<font color='#5555FF'>&amp;</font> interp,
        <font color='#0000FF'>const</font> point_mapping_type<font color='#5555FF'>&amp;</font> map_point
    <font face='Lucida Console'>)</font>
    <b>{</b>
        <font color='#009900'>// make sure requires clause is not broken
</font>        <font color='#BB00BB'>DLIB_ASSERT</font><font face='Lucida Console'>(</font> <font color='#BB00BB'>is_same_object</font><font face='Lucida Console'>(</font>in_img, out_img<font face='Lucida Console'>)</font> <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>false</font> ,
            "<font color='#CC0000'>\t void transform_image()</font>"
            <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t Invalid inputs were given to this function.</font>"
            <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t is_same_object(in_img, out_img):  </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> <font color='#BB00BB'>is_same_object</font><font face='Lucida Console'>(</font>in_img, out_img<font face='Lucida Console'>)</font>
            <font face='Lucida Console'>)</font>;


        <font color='#BB00BB'>transform_image</font><font face='Lucida Console'>(</font>in_img, out_img, interp, map_point, <font color='#BB00BB'>black_background</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>, <font color='#BB00BB'>get_rect</font><font face='Lucida Console'>(</font>out_img<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
    <b>}</b>

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font>
        <font color='#0000FF'>typename</font> image_type1,
        <font color='#0000FF'>typename</font> image_type2,
        <font color='#0000FF'>typename</font> interpolation_type
        <font color='#5555FF'>&gt;</font>
    point_transform_affine <b><a name='rotate_image'></a>rotate_image</b> <font face='Lucida Console'>(</font>
        <font color='#0000FF'>const</font> image_type1<font color='#5555FF'>&amp;</font> in_img,
        image_type2<font color='#5555FF'>&amp;</font> out_img,
        <font color='#0000FF'><u>double</u></font> angle,
        <font color='#0000FF'>const</font> interpolation_type<font color='#5555FF'>&amp;</font> interp
    <font face='Lucida Console'>)</font>
    <b>{</b>
        <font color='#009900'>// make sure requires clause is not broken
</font>        <font color='#BB00BB'>DLIB_ASSERT</font><font face='Lucida Console'>(</font> <font color='#BB00BB'>is_same_object</font><font face='Lucida Console'>(</font>in_img, out_img<font face='Lucida Console'>)</font> <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>false</font> ,
            "<font color='#CC0000'>\t point_transform_affine rotate_image()</font>"
            <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t Invalid inputs were given to this function.</font>"
            <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t is_same_object(in_img, out_img):  </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> <font color='#BB00BB'>is_same_object</font><font face='Lucida Console'>(</font>in_img, out_img<font face='Lucida Console'>)</font>
            <font face='Lucida Console'>)</font>;

        <font color='#0000FF'>const</font> rectangle rimg <font color='#5555FF'>=</font> <font color='#BB00BB'>get_rect</font><font face='Lucida Console'>(</font>in_img<font face='Lucida Console'>)</font>;


        <font color='#009900'>// figure out bounding box for rotated rectangle
</font>        rectangle rect;
        rect <font color='#5555FF'>+</font><font color='#5555FF'>=</font> <font color='#BB00BB'>rotate_point</font><font face='Lucida Console'>(</font><font color='#BB00BB'>center</font><font face='Lucida Console'>(</font>rimg<font face='Lucida Console'>)</font>, rimg.<font color='#BB00BB'>tl_corner</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>, <font color='#5555FF'>-</font>angle<font face='Lucida Console'>)</font>;
        rect <font color='#5555FF'>+</font><font color='#5555FF'>=</font> <font color='#BB00BB'>rotate_point</font><font face='Lucida Console'>(</font><font color='#BB00BB'>center</font><font face='Lucida Console'>(</font>rimg<font face='Lucida Console'>)</font>, rimg.<font color='#BB00BB'>tr_corner</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>, <font color='#5555FF'>-</font>angle<font face='Lucida Console'>)</font>;
        rect <font color='#5555FF'>+</font><font color='#5555FF'>=</font> <font color='#BB00BB'>rotate_point</font><font face='Lucida Console'>(</font><font color='#BB00BB'>center</font><font face='Lucida Console'>(</font>rimg<font face='Lucida Console'>)</font>, rimg.<font color='#BB00BB'>bl_corner</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>, <font color='#5555FF'>-</font>angle<font face='Lucida Console'>)</font>;
        rect <font color='#5555FF'>+</font><font color='#5555FF'>=</font> <font color='#BB00BB'>rotate_point</font><font face='Lucida Console'>(</font><font color='#BB00BB'>center</font><font face='Lucida Console'>(</font>rimg<font face='Lucida Console'>)</font>, rimg.<font color='#BB00BB'>br_corner</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>, <font color='#5555FF'>-</font>angle<font face='Lucida Console'>)</font>;
        <font color='#BB00BB'>set_image_size</font><font face='Lucida Console'>(</font>out_img, rect.<font color='#BB00BB'>height</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>, rect.<font color='#BB00BB'>width</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;

        <font color='#0000FF'>const</font> matrix<font color='#5555FF'>&lt;</font><font color='#0000FF'><u>double</u></font>,<font color='#979000'>2</font>,<font color='#979000'>2</font><font color='#5555FF'>&gt;</font> R <font color='#5555FF'>=</font> <font color='#BB00BB'>rotation_matrix</font><font face='Lucida Console'>(</font>angle<font face='Lucida Console'>)</font>;

        point_transform_affine trans <font color='#5555FF'>=</font> <font color='#BB00BB'>point_transform_affine</font><font face='Lucida Console'>(</font>R, <font color='#5555FF'>-</font>R<font color='#5555FF'>*</font><font color='#BB00BB'>dcenter</font><font face='Lucida Console'>(</font><font color='#BB00BB'>get_rect</font><font face='Lucida Console'>(</font>out_img<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font> <font color='#5555FF'>+</font> <font color='#BB00BB'>dcenter</font><font face='Lucida Console'>(</font>rimg<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
        <font color='#BB00BB'>transform_image</font><font face='Lucida Console'>(</font>in_img, out_img, interp, trans<font face='Lucida Console'>)</font>;
        <font color='#0000FF'>return</font> <font color='#BB00BB'>inv</font><font face='Lucida Console'>(</font>trans<font face='Lucida Console'>)</font>;
    <b>}</b>

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font>
        <font color='#0000FF'>typename</font> image_type1,
        <font color='#0000FF'>typename</font> image_type2
        <font color='#5555FF'>&gt;</font>
    point_transform_affine <b><a name='rotate_image'></a>rotate_image</b> <font face='Lucida Console'>(</font>
        <font color='#0000FF'>const</font> image_type1<font color='#5555FF'>&amp;</font> in_img,
        image_type2<font color='#5555FF'>&amp;</font> out_img,
        <font color='#0000FF'><u>double</u></font> angle
    <font face='Lucida Console'>)</font>
    <b>{</b>
        <font color='#009900'>// make sure requires clause is not broken
</font>        <font color='#BB00BB'>DLIB_ASSERT</font><font face='Lucida Console'>(</font> <font color='#BB00BB'>is_same_object</font><font face='Lucida Console'>(</font>in_img, out_img<font face='Lucida Console'>)</font> <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>false</font> ,
            "<font color='#CC0000'>\t point_transform_affine rotate_image()</font>"
            <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t Invalid inputs were given to this function.</font>"
            <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t is_same_object(in_img, out_img):  </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> <font color='#BB00BB'>is_same_object</font><font face='Lucida Console'>(</font>in_img, out_img<font face='Lucida Console'>)</font>
            <font face='Lucida Console'>)</font>;

        <font color='#0000FF'>return</font> <font color='#BB00BB'>rotate_image</font><font face='Lucida Console'>(</font>in_img, out_img, angle, <font color='#BB00BB'>interpolate_quadratic</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
    <b>}</b>

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
    <font color='#0000FF'>namespace</font> impl
    <b>{</b>
        <font color='#0000FF'>class</font> <b><a name='helper_resize_image'></a>helper_resize_image</b> 
        <b>{</b>
        <font color='#0000FF'>public</font>:
            <b><a name='helper_resize_image'></a>helper_resize_image</b><font face='Lucida Console'>(</font>
                <font color='#0000FF'><u>double</u></font> x_scale_,
                <font color='#0000FF'><u>double</u></font> y_scale_
            <font face='Lucida Console'>)</font>:
                x_scale<font face='Lucida Console'>(</font>x_scale_<font face='Lucida Console'>)</font>,
                y_scale<font face='Lucida Console'>(</font>y_scale_<font face='Lucida Console'>)</font>
            <b>{</b><b>}</b>

            dlib::vector<font color='#5555FF'>&lt;</font><font color='#0000FF'><u>double</u></font>,<font color='#979000'>2</font><font color='#5555FF'>&gt;</font> <b><a name='operator'></a>operator</b><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font face='Lucida Console'>(</font>
                <font color='#0000FF'>const</font> dlib::vector<font color='#5555FF'>&lt;</font><font color='#0000FF'><u>double</u></font>,<font color='#979000'>2</font><font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> p
            <font face='Lucida Console'>)</font> <font color='#0000FF'>const</font>
            <b>{</b>
                <font color='#0000FF'>return</font> dlib::vector<font color='#5555FF'>&lt;</font><font color='#0000FF'><u>double</u></font>,<font color='#979000'>2</font><font color='#5555FF'>&gt;</font><font face='Lucida Console'>(</font>p.<font color='#BB00BB'>x</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font color='#5555FF'>*</font>x_scale, p.<font color='#BB00BB'>y</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font color='#5555FF'>*</font>y_scale<font face='Lucida Console'>)</font>;
            <b>}</b>

        <font color='#0000FF'>private</font>:
            <font color='#0000FF'>const</font> <font color='#0000FF'><u>double</u></font> x_scale;
            <font color='#0000FF'>const</font> <font color='#0000FF'><u>double</u></font> y_scale;
        <b>}</b>;
    <b>}</b>

    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font>
        <font color='#0000FF'>typename</font> image_type1,
        <font color='#0000FF'>typename</font> image_type2,
        <font color='#0000FF'>typename</font> interpolation_type
        <font color='#5555FF'>&gt;</font>
    <font color='#0000FF'><u>void</u></font> <b><a name='resize_image'></a>resize_image</b> <font face='Lucida Console'>(</font>
        <font color='#0000FF'>const</font> image_type1<font color='#5555FF'>&amp;</font> in_img,
        image_type2<font color='#5555FF'>&amp;</font> out_img,
        <font color='#0000FF'>const</font> interpolation_type<font color='#5555FF'>&amp;</font> interp
    <font face='Lucida Console'>)</font>
    <b>{</b>
        <font color='#009900'>// make sure requires clause is not broken
</font>        <font color='#BB00BB'>DLIB_ASSERT</font><font face='Lucida Console'>(</font> <font color='#BB00BB'>is_same_object</font><font face='Lucida Console'>(</font>in_img, out_img<font face='Lucida Console'>)</font> <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>false</font> ,
            "<font color='#CC0000'>\t void resize_image()</font>"
            <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t Invalid inputs were given to this function.</font>"
            <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t is_same_object(in_img, out_img):  </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> <font color='#BB00BB'>is_same_object</font><font face='Lucida Console'>(</font>in_img, out_img<font face='Lucida Console'>)</font>
            <font face='Lucida Console'>)</font>;

        <font color='#0000FF'>const</font> <font color='#0000FF'><u>double</u></font> x_scale <font color='#5555FF'>=</font> <font face='Lucida Console'>(</font><font color='#BB00BB'>num_columns</font><font face='Lucida Console'>(</font>in_img<font face='Lucida Console'>)</font><font color='#5555FF'>-</font><font color='#979000'>1</font><font face='Lucida Console'>)</font><font color='#5555FF'>/</font><font face='Lucida Console'>(</font><font color='#0000FF'><u>double</u></font><font face='Lucida Console'>)</font>std::max<font color='#5555FF'>&lt;</font><font color='#0000FF'><u>long</u></font><font color='#5555FF'>&gt;</font><font face='Lucida Console'>(</font><font face='Lucida Console'>(</font><font color='#BB00BB'>num_columns</font><font face='Lucida Console'>(</font>out_img<font face='Lucida Console'>)</font><font color='#5555FF'>-</font><font color='#979000'>1</font><font face='Lucida Console'>)</font>,<font color='#979000'>1</font><font face='Lucida Console'>)</font>;
        <font color='#0000FF'>const</font> <font color='#0000FF'><u>double</u></font> y_scale <font color='#5555FF'>=</font> <font face='Lucida Console'>(</font><font color='#BB00BB'>num_rows</font><font face='Lucida Console'>(</font>in_img<font face='Lucida Console'>)</font><font color='#5555FF'>-</font><font color='#979000'>1</font><font face='Lucida Console'>)</font><font color='#5555FF'>/</font><font face='Lucida Console'>(</font><font color='#0000FF'><u>double</u></font><font face='Lucida Console'>)</font>std::max<font color='#5555FF'>&lt;</font><font color='#0000FF'><u>long</u></font><font color='#5555FF'>&gt;</font><font face='Lucida Console'>(</font><font face='Lucida Console'>(</font><font color='#BB00BB'>num_rows</font><font face='Lucida Console'>(</font>out_img<font face='Lucida Console'>)</font><font color='#5555FF'>-</font><font color='#979000'>1</font><font face='Lucida Console'>)</font>,<font color='#979000'>1</font><font face='Lucida Console'>)</font>;
        <font color='#BB00BB'>transform_image</font><font face='Lucida Console'>(</font>in_img, out_img, interp, 
                        dlib::impl::<font color='#BB00BB'>helper_resize_image</font><font face='Lucida Console'>(</font>x_scale,y_scale<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
    <b>}</b>

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font><font color='#0000FF'>typename</font> image_type<font color='#5555FF'>&gt;</font>
    <font color='#0000FF'>struct</font> <b><a name='is_rgb_image'></a>is_rgb_image</b> <b>{</b> <font color='#0000FF'>const</font> <font color='#0000FF'>static</font> <font color='#0000FF'><u>bool</u></font> value <font color='#5555FF'>=</font> pixel_traits<font color='#5555FF'>&lt;</font><font color='#0000FF'>typename</font> image_traits<font color='#5555FF'>&lt;</font>image_type<font color='#5555FF'>&gt;</font>::pixel_type<font color='#5555FF'>&gt;</font>::rgb; <b>}</b>;
    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font><font color='#0000FF'>typename</font> image_type<font color='#5555FF'>&gt;</font>
    <font color='#0000FF'>struct</font> <b><a name='is_grayscale_image'></a>is_grayscale_image</b> <b>{</b> <font color='#0000FF'>const</font> <font color='#0000FF'>static</font> <font color='#0000FF'><u>bool</u></font> value <font color='#5555FF'>=</font> pixel_traits<font color='#5555FF'>&lt;</font><font color='#0000FF'>typename</font> image_traits<font color='#5555FF'>&lt;</font>image_type<font color='#5555FF'>&gt;</font>::pixel_type<font color='#5555FF'>&gt;</font>::grayscale; <b>}</b>;

    <font color='#009900'>// This is an optimized version of resize_image for the case where bilinear
</font>    <font color='#009900'>// interpolation is used.
</font>    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font>
        <font color='#0000FF'>typename</font> image_type1,
        <font color='#0000FF'>typename</font> image_type2
        <font color='#5555FF'>&gt;</font>
    <font color='#0000FF'>typename</font> disable_if_c<font color='#5555FF'>&lt;</font><font face='Lucida Console'>(</font>is_rgb_image<font color='#5555FF'>&lt;</font>image_type1<font color='#5555FF'>&gt;</font>::value<font color='#5555FF'>&amp;</font><font color='#5555FF'>&amp;</font>is_rgb_image<font color='#5555FF'>&lt;</font>image_type2<font color='#5555FF'>&gt;</font>::value<font face='Lucida Console'>)</font> <font color='#5555FF'>|</font><font color='#5555FF'>|</font> 
                          <font face='Lucida Console'>(</font>is_grayscale_image<font color='#5555FF'>&lt;</font>image_type1<font color='#5555FF'>&gt;</font>::value<font color='#5555FF'>&amp;</font><font color='#5555FF'>&amp;</font>is_grayscale_image<font color='#5555FF'>&lt;</font>image_type2<font color='#5555FF'>&gt;</font>::value<font face='Lucida Console'>)</font><font color='#5555FF'>&gt;</font>::type 
    <b><a name='resize_image'></a>resize_image</b> <font face='Lucida Console'>(</font>
        <font color='#0000FF'>const</font> image_type1<font color='#5555FF'>&amp;</font> in_img_,
        image_type2<font color='#5555FF'>&amp;</font> out_img_,
        interpolate_bilinear
    <font face='Lucida Console'>)</font>
    <b>{</b>
        <font color='#009900'>// make sure requires clause is not broken
</font>        <font color='#BB00BB'>DLIB_ASSERT</font><font face='Lucida Console'>(</font> <font color='#BB00BB'>is_same_object</font><font face='Lucida Console'>(</font>in_img_, out_img_<font face='Lucida Console'>)</font> <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>false</font> ,
            "<font color='#CC0000'>\t void resize_image()</font>"
            <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t Invalid inputs were given to this function.</font>"
            <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t is_same_object(in_img_, out_img_):  </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> <font color='#BB00BB'>is_same_object</font><font face='Lucida Console'>(</font>in_img_, out_img_<font face='Lucida Console'>)</font>
            <font face='Lucida Console'>)</font>;

        const_image_view<font color='#5555FF'>&lt;</font>image_type1<font color='#5555FF'>&gt;</font> <font color='#BB00BB'>in_img</font><font face='Lucida Console'>(</font>in_img_<font face='Lucida Console'>)</font>;
        image_view<font color='#5555FF'>&lt;</font>image_type2<font color='#5555FF'>&gt;</font> <font color='#BB00BB'>out_img</font><font face='Lucida Console'>(</font>out_img_<font face='Lucida Console'>)</font>;

        <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>out_img.<font color='#BB00BB'>nr</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>&lt;</font><font color='#5555FF'>=</font> <font color='#979000'>1</font> <font color='#5555FF'>|</font><font color='#5555FF'>|</font> out_img.<font color='#BB00BB'>nc</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>&lt;</font><font color='#5555FF'>=</font> <font color='#979000'>1</font><font face='Lucida Console'>)</font>
        <b>{</b>
            <font color='#BB00BB'>assign_all_pixels</font><font face='Lucida Console'>(</font>out_img, <font color='#979000'>0</font><font face='Lucida Console'>)</font>;
            <font color='#0000FF'>return</font>;
        <b>}</b>


        <font color='#0000FF'>typedef</font> <font color='#0000FF'>typename</font> image_traits<font color='#5555FF'>&lt;</font>image_type1<font color='#5555FF'>&gt;</font>::pixel_type T;
        <font color='#0000FF'>typedef</font> <font color='#0000FF'>typename</font> image_traits<font color='#5555FF'>&lt;</font>image_type2<font color='#5555FF'>&gt;</font>::pixel_type U;
        <font color='#0000FF'>const</font> <font color='#0000FF'><u>double</u></font> x_scale <font color='#5555FF'>=</font> <font face='Lucida Console'>(</font>in_img.<font color='#BB00BB'>nc</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font color='#5555FF'>-</font><font color='#979000'>1</font><font face='Lucida Console'>)</font><font color='#5555FF'>/</font><font face='Lucida Console'>(</font><font color='#0000FF'><u>double</u></font><font face='Lucida Console'>)</font>std::max<font color='#5555FF'>&lt;</font><font color='#0000FF'><u>long</u></font><font color='#5555FF'>&gt;</font><font face='Lucida Console'>(</font><font face='Lucida Console'>(</font>out_img.<font color='#BB00BB'>nc</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font color='#5555FF'>-</font><font color='#979000'>1</font><font face='Lucida Console'>)</font>,<font color='#979000'>1</font><font face='Lucida Console'>)</font>;
        <font color='#0000FF'>const</font> <font color='#0000FF'><u>double</u></font> y_scale <font color='#5555FF'>=</font> <font face='Lucida Console'>(</font>in_img.<font color='#BB00BB'>nr</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font color='#5555FF'>-</font><font color='#979000'>1</font><font face='Lucida Console'>)</font><font color='#5555FF'>/</font><font face='Lucida Console'>(</font><font color='#0000FF'><u>double</u></font><font face='Lucida Console'>)</font>std::max<font color='#5555FF'>&lt;</font><font color='#0000FF'><u>long</u></font><font color='#5555FF'>&gt;</font><font face='Lucida Console'>(</font><font face='Lucida Console'>(</font>out_img.<font color='#BB00BB'>nr</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font color='#5555FF'>-</font><font color='#979000'>1</font><font face='Lucida Console'>)</font>,<font color='#979000'>1</font><font face='Lucida Console'>)</font>;
        <font color='#0000FF'><u>double</u></font> y <font color='#5555FF'>=</font> <font color='#5555FF'>-</font>y_scale;
        <font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>long</u></font> r <font color='#5555FF'>=</font> <font color='#979000'>0</font>; r <font color='#5555FF'>&lt;</font> out_img.<font color='#BB00BB'>nr</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>; <font color='#5555FF'>+</font><font color='#5555FF'>+</font>r<font face='Lucida Console'>)</font>
        <b>{</b>
            y <font color='#5555FF'>+</font><font color='#5555FF'>=</font> y_scale;
            <font color='#0000FF'>const</font> <font color='#0000FF'><u>long</u></font> top    <font color='#5555FF'>=</font> <font color='#0000FF'>static_cast</font><font color='#5555FF'>&lt;</font><font color='#0000FF'><u>long</u></font><font color='#5555FF'>&gt;</font><font face='Lucida Console'>(</font>std::<font color='#BB00BB'>floor</font><font face='Lucida Console'>(</font>y<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
            <font color='#0000FF'>const</font> <font color='#0000FF'><u>long</u></font> bottom <font color='#5555FF'>=</font> std::<font color='#BB00BB'>min</font><font face='Lucida Console'>(</font>top<font color='#5555FF'>+</font><font color='#979000'>1</font>, in_img.<font color='#BB00BB'>nr</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font color='#5555FF'>-</font><font color='#979000'>1</font><font face='Lucida Console'>)</font>;
            <font color='#0000FF'>const</font> <font color='#0000FF'><u>double</u></font> tb_frac <font color='#5555FF'>=</font> y <font color='#5555FF'>-</font> top;
            <font color='#0000FF'><u>double</u></font> x <font color='#5555FF'>=</font> <font color='#5555FF'>-</font>x_scale;
            <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>pixel_traits<font color='#5555FF'>&lt;</font>U<font color='#5555FF'>&gt;</font>::grayscale<font face='Lucida Console'>)</font>
            <b>{</b>
                <font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>long</u></font> c <font color='#5555FF'>=</font> <font color='#979000'>0</font>; c <font color='#5555FF'>&lt;</font> out_img.<font color='#BB00BB'>nc</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>; <font color='#5555FF'>+</font><font color='#5555FF'>+</font>c<font face='Lucida Console'>)</font>
                <b>{</b>
                    x <font color='#5555FF'>+</font><font color='#5555FF'>=</font> x_scale;
                    <font color='#0000FF'>const</font> <font color='#0000FF'><u>long</u></font> left   <font color='#5555FF'>=</font> <font color='#0000FF'>static_cast</font><font color='#5555FF'>&lt;</font><font color='#0000FF'><u>long</u></font><font color='#5555FF'>&gt;</font><font face='Lucida Console'>(</font>std::<font color='#BB00BB'>floor</font><font face='Lucida Console'>(</font>x<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
                    <font color='#0000FF'>const</font> <font color='#0000FF'><u>long</u></font> right  <font color='#5555FF'>=</font> std::<font color='#BB00BB'>min</font><font face='Lucida Console'>(</font>left<font color='#5555FF'>+</font><font color='#979000'>1</font>, in_img.<font color='#BB00BB'>nc</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font color='#5555FF'>-</font><font color='#979000'>1</font><font face='Lucida Console'>)</font>;
                    <font color='#0000FF'>const</font> <font color='#0000FF'><u>double</u></font> lr_frac <font color='#5555FF'>=</font> x <font color='#5555FF'>-</font> left;

                    <font color='#0000FF'><u>double</u></font> tl <font color='#5555FF'>=</font> <font color='#979000'>0</font>, tr <font color='#5555FF'>=</font> <font color='#979000'>0</font>, bl <font color='#5555FF'>=</font> <font color='#979000'>0</font>, br <font color='#5555FF'>=</font> <font color='#979000'>0</font>;

                    <font color='#BB00BB'>assign_pixel</font><font face='Lucida Console'>(</font>tl, in_img[top][left]<font face='Lucida Console'>)</font>;
                    <font color='#BB00BB'>assign_pixel</font><font face='Lucida Console'>(</font>tr, in_img[top][right]<font face='Lucida Console'>)</font>;
                    <font color='#BB00BB'>assign_pixel</font><font face='Lucida Console'>(</font>bl, in_img[bottom][left]<font face='Lucida Console'>)</font>;
                    <font color='#BB00BB'>assign_pixel</font><font face='Lucida Console'>(</font>br, in_img[bottom][right]<font face='Lucida Console'>)</font>;

                    <font color='#0000FF'><u>double</u></font> temp <font color='#5555FF'>=</font> <font face='Lucida Console'>(</font><font color='#979000'>1</font><font color='#5555FF'>-</font>tb_frac<font face='Lucida Console'>)</font><font color='#5555FF'>*</font><font face='Lucida Console'>(</font><font face='Lucida Console'>(</font><font color='#979000'>1</font><font color='#5555FF'>-</font>lr_frac<font face='Lucida Console'>)</font><font color='#5555FF'>*</font>tl <font color='#5555FF'>+</font> lr_frac<font color='#5555FF'>*</font>tr<font face='Lucida Console'>)</font> <font color='#5555FF'>+</font> 
                        tb_frac<font color='#5555FF'>*</font><font face='Lucida Console'>(</font><font face='Lucida Console'>(</font><font color='#979000'>1</font><font color='#5555FF'>-</font>lr_frac<font face='Lucida Console'>)</font><font color='#5555FF'>*</font>bl <font color='#5555FF'>+</font> lr_frac<font color='#5555FF'>*</font>br<font face='Lucida Console'>)</font>;

                    <font color='#BB00BB'>assign_pixel</font><font face='Lucida Console'>(</font>out_img[r][c], temp<font face='Lucida Console'>)</font>;
                <b>}</b>
            <b>}</b>
            <font color='#0000FF'>else</font>
            <b>{</b>
                <font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>long</u></font> c <font color='#5555FF'>=</font> <font color='#979000'>0</font>; c <font color='#5555FF'>&lt;</font> out_img.<font color='#BB00BB'>nc</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>; <font color='#5555FF'>+</font><font color='#5555FF'>+</font>c<font face='Lucida Console'>)</font>
                <b>{</b>
                    x <font color='#5555FF'>+</font><font color='#5555FF'>=</font> x_scale;
                    <font color='#0000FF'>const</font> <font color='#0000FF'><u>long</u></font> left   <font color='#5555FF'>=</font> <font color='#0000FF'>static_cast</font><font color='#5555FF'>&lt;</font><font color='#0000FF'><u>long</u></font><font color='#5555FF'>&gt;</font><font face='Lucida Console'>(</font>std::<font color='#BB00BB'>floor</font><font face='Lucida Console'>(</font>x<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
                    <font color='#0000FF'>const</font> <font color='#0000FF'><u>long</u></font> right  <font color='#5555FF'>=</font> std::<font color='#BB00BB'>min</font><font face='Lucida Console'>(</font>left<font color='#5555FF'>+</font><font color='#979000'>1</font>, in_img.<font color='#BB00BB'>nc</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font color='#5555FF'>-</font><font color='#979000'>1</font><font face='Lucida Console'>)</font>;
                    <font color='#0000FF'>const</font> <font color='#0000FF'><u>double</u></font> lr_frac <font color='#5555FF'>=</font> x <font color='#5555FF'>-</font> left;

                    <font color='#0000FF'>const</font> T tl <font color='#5555FF'>=</font> in_img[top][left];
                    <font color='#0000FF'>const</font> T tr <font color='#5555FF'>=</font> in_img[top][right];
                    <font color='#0000FF'>const</font> T bl <font color='#5555FF'>=</font> in_img[bottom][left];
                    <font color='#0000FF'>const</font> T br <font color='#5555FF'>=</font> in_img[bottom][right];

                    T temp;
                    <font color='#BB00BB'>assign_pixel</font><font face='Lucida Console'>(</font>temp, <font color='#979000'>0</font><font face='Lucida Console'>)</font>;
                    <font color='#BB00BB'>vector_to_pixel</font><font face='Lucida Console'>(</font>temp, 
                        <font face='Lucida Console'>(</font><font color='#979000'>1</font><font color='#5555FF'>-</font>tb_frac<font face='Lucida Console'>)</font><font color='#5555FF'>*</font><font face='Lucida Console'>(</font><font face='Lucida Console'>(</font><font color='#979000'>1</font><font color='#5555FF'>-</font>lr_frac<font face='Lucida Console'>)</font><font color='#5555FF'>*</font>pixel_to_vector<font color='#5555FF'>&lt;</font><font color='#0000FF'><u>double</u></font><font color='#5555FF'>&gt;</font><font face='Lucida Console'>(</font>tl<font face='Lucida Console'>)</font> <font color='#5555FF'>+</font> lr_frac<font color='#5555FF'>*</font>pixel_to_vector<font color='#5555FF'>&lt;</font><font color='#0000FF'><u>double</u></font><font color='#5555FF'>&gt;</font><font face='Lucida Console'>(</font>tr<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font> <font color='#5555FF'>+</font> 
                            tb_frac<font color='#5555FF'>*</font><font face='Lucida Console'>(</font><font face='Lucida Console'>(</font><font color='#979000'>1</font><font color='#5555FF'>-</font>lr_frac<font face='Lucida Console'>)</font><font color='#5555FF'>*</font>pixel_to_vector<font color='#5555FF'>&lt;</font><font color='#0000FF'><u>double</u></font><font color='#5555FF'>&gt;</font><font face='Lucida Console'>(</font>bl<font face='Lucida Console'>)</font> <font color='#5555FF'>+</font> lr_frac<font color='#5555FF'>*</font>pixel_to_vector<font color='#5555FF'>&lt;</font><font color='#0000FF'><u>double</u></font><font color='#5555FF'>&gt;</font><font face='Lucida Console'>(</font>br<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
                    <font color='#BB00BB'>assign_pixel</font><font face='Lucida Console'>(</font>out_img[r][c], temp<font face='Lucida Console'>)</font>;
                <b>}</b>
            <b>}</b>
        <b>}</b>
    <b>}</b>

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font>
        <font color='#0000FF'>typename</font> image_type
        <font color='#5555FF'>&gt;</font>
    <font color='#0000FF'>typename</font> enable_if<font color='#5555FF'>&lt;</font>is_grayscale_image<font color='#5555FF'>&lt;</font>image_type<font color='#5555FF'>&gt;</font> <font color='#5555FF'>&gt;</font>::type <b><a name='resize_image'></a>resize_image</b> <font face='Lucida Console'>(</font>
        <font color='#0000FF'>const</font> image_type<font color='#5555FF'>&amp;</font> in_img_,
        image_type<font color='#5555FF'>&amp;</font> out_img_,
        interpolate_bilinear
    <font face='Lucida Console'>)</font>
    <b>{</b>
        <font color='#009900'>// make sure requires clause is not broken
</font>        <font color='#BB00BB'>DLIB_ASSERT</font><font face='Lucida Console'>(</font> <font color='#BB00BB'>is_same_object</font><font face='Lucida Console'>(</font>in_img_, out_img_<font face='Lucida Console'>)</font> <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>false</font> ,
            "<font color='#CC0000'>\t void resize_image()</font>"
            <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t Invalid inputs were given to this function.</font>"
            <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t is_same_object(in_img_, out_img_):  </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> <font color='#BB00BB'>is_same_object</font><font face='Lucida Console'>(</font>in_img_, out_img_<font face='Lucida Console'>)</font>
            <font face='Lucida Console'>)</font>;

        const_image_view<font color='#5555FF'>&lt;</font>image_type<font color='#5555FF'>&gt;</font> <font color='#BB00BB'>in_img</font><font face='Lucida Console'>(</font>in_img_<font face='Lucida Console'>)</font>;
        image_view<font color='#5555FF'>&lt;</font>image_type<font color='#5555FF'>&gt;</font> <font color='#BB00BB'>out_img</font><font face='Lucida Console'>(</font>out_img_<font face='Lucida Console'>)</font>;

        <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>out_img.<font color='#BB00BB'>nr</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>&lt;</font><font color='#5555FF'>=</font> <font color='#979000'>1</font> <font color='#5555FF'>|</font><font color='#5555FF'>|</font> out_img.<font color='#BB00BB'>nc</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>&lt;</font><font color='#5555FF'>=</font> <font color='#979000'>1</font><font face='Lucida Console'>)</font>
        <b>{</b>
            <font color='#BB00BB'>assign_all_pixels</font><font face='Lucida Console'>(</font>out_img, <font color='#979000'>0</font><font face='Lucida Console'>)</font>;
            <font color='#0000FF'>return</font>;
        <b>}</b>

        <font color='#0000FF'>typedef</font> <font color='#0000FF'>typename</font> image_traits<font color='#5555FF'>&lt;</font>image_type<font color='#5555FF'>&gt;</font>::pixel_type T;
        <font color='#0000FF'>const</font> <font color='#0000FF'><u>double</u></font> x_scale <font color='#5555FF'>=</font> <font face='Lucida Console'>(</font>in_img.<font color='#BB00BB'>nc</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font color='#5555FF'>-</font><font color='#979000'>1</font><font face='Lucida Console'>)</font><font color='#5555FF'>/</font><font face='Lucida Console'>(</font><font color='#0000FF'><u>double</u></font><font face='Lucida Console'>)</font>std::max<font color='#5555FF'>&lt;</font><font color='#0000FF'><u>long</u></font><font color='#5555FF'>&gt;</font><font face='Lucida Console'>(</font><font face='Lucida Console'>(</font>out_img.<font color='#BB00BB'>nc</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font color='#5555FF'>-</font><font color='#979000'>1</font><font face='Lucida Console'>)</font>,<font color='#979000'>1</font><font face='Lucida Console'>)</font>;
        <font color='#0000FF'>const</font> <font color='#0000FF'><u>double</u></font> y_scale <font color='#5555FF'>=</font> <font face='Lucida Console'>(</font>in_img.<font color='#BB00BB'>nr</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font color='#5555FF'>-</font><font color='#979000'>1</font><font face='Lucida Console'>)</font><font color='#5555FF'>/</font><font face='Lucida Console'>(</font><font color='#0000FF'><u>double</u></font><font face='Lucida Console'>)</font>std::max<font color='#5555FF'>&lt;</font><font color='#0000FF'><u>long</u></font><font color='#5555FF'>&gt;</font><font face='Lucida Console'>(</font><font face='Lucida Console'>(</font>out_img.<font color='#BB00BB'>nr</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font color='#5555FF'>-</font><font color='#979000'>1</font><font face='Lucida Console'>)</font>,<font color='#979000'>1</font><font face='Lucida Console'>)</font>;
        <font color='#0000FF'><u>double</u></font> y <font color='#5555FF'>=</font> <font color='#5555FF'>-</font>y_scale;
        <font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>long</u></font> r <font color='#5555FF'>=</font> <font color='#979000'>0</font>; r <font color='#5555FF'>&lt;</font> out_img.<font color='#BB00BB'>nr</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>; <font color='#5555FF'>+</font><font color='#5555FF'>+</font>r<font face='Lucida Console'>)</font>
        <b>{</b>
            y <font color='#5555FF'>+</font><font color='#5555FF'>=</font> y_scale;
            <font color='#0000FF'>const</font> <font color='#0000FF'><u>long</u></font> top    <font color='#5555FF'>=</font> <font color='#0000FF'>static_cast</font><font color='#5555FF'>&lt;</font><font color='#0000FF'><u>long</u></font><font color='#5555FF'>&gt;</font><font face='Lucida Console'>(</font>std::<font color='#BB00BB'>floor</font><font face='Lucida Console'>(</font>y<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
            <font color='#0000FF'>const</font> <font color='#0000FF'><u>long</u></font> bottom <font color='#5555FF'>=</font> std::<font color='#BB00BB'>min</font><font face='Lucida Console'>(</font>top<font color='#5555FF'>+</font><font color='#979000'>1</font>, in_img.<font color='#BB00BB'>nr</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font color='#5555FF'>-</font><font color='#979000'>1</font><font face='Lucida Console'>)</font>;
            <font color='#0000FF'>const</font> <font color='#0000FF'><u>double</u></font> tb_frac <font color='#5555FF'>=</font> y <font color='#5555FF'>-</font> top;
            <font color='#0000FF'><u>double</u></font> x <font color='#5555FF'>=</font> <font color='#5555FF'>-</font><font color='#979000'>4</font><font color='#5555FF'>*</font>x_scale;

            <font color='#0000FF'>const</font> simd4f _tb_frac <font color='#5555FF'>=</font> tb_frac;
            <font color='#0000FF'>const</font> simd4f _inv_tb_frac <font color='#5555FF'>=</font> <font color='#979000'>1</font><font color='#5555FF'>-</font>tb_frac;
            <font color='#0000FF'>const</font> simd4f _x_scale <font color='#5555FF'>=</font> <font color='#979000'>4</font><font color='#5555FF'>*</font>x_scale;
            simd4f <font color='#BB00BB'>_x</font><font face='Lucida Console'>(</font>x, x<font color='#5555FF'>+</font>x_scale, x<font color='#5555FF'>+</font><font color='#979000'>2</font><font color='#5555FF'>*</font>x_scale, x<font color='#5555FF'>+</font><font color='#979000'>3</font><font color='#5555FF'>*</font>x_scale<font face='Lucida Console'>)</font>;
            <font color='#0000FF'><u>long</u></font> c <font color='#5555FF'>=</font> <font color='#979000'>0</font>;
            <font color='#0000FF'>for</font> <font face='Lucida Console'>(</font>;; c<font color='#5555FF'>+</font><font color='#5555FF'>=</font><font color='#979000'>4</font><font face='Lucida Console'>)</font>
            <b>{</b>
                _x <font color='#5555FF'>+</font><font color='#5555FF'>=</font> _x_scale;
                simd4i left <font color='#5555FF'>=</font> <font color='#BB00BB'>simd4i</font><font face='Lucida Console'>(</font>_x<font face='Lucida Console'>)</font>;

                simd4f _lr_frac <font color='#5555FF'>=</font> _x<font color='#5555FF'>-</font>left;
                simd4f _inv_lr_frac <font color='#5555FF'>=</font> <font color='#979000'>1</font><font color='#5555FF'>-</font>_lr_frac; 
                simd4i right <font color='#5555FF'>=</font> left<font color='#5555FF'>+</font><font color='#979000'>1</font>;

                simd4f tlf <font color='#5555FF'>=</font> _inv_tb_frac<font color='#5555FF'>*</font>_inv_lr_frac;
                simd4f trf <font color='#5555FF'>=</font> _inv_tb_frac<font color='#5555FF'>*</font>_lr_frac;
                simd4f blf <font color='#5555FF'>=</font> _tb_frac<font color='#5555FF'>*</font>_inv_lr_frac;
                simd4f brf <font color='#5555FF'>=</font> _tb_frac<font color='#5555FF'>*</font>_lr_frac;

                int32 fleft[<font color='#979000'>4</font>];
                int32 fright[<font color='#979000'>4</font>];
                left.<font color='#BB00BB'>store</font><font face='Lucida Console'>(</font>fleft<font face='Lucida Console'>)</font>;
                right.<font color='#BB00BB'>store</font><font face='Lucida Console'>(</font>fright<font face='Lucida Console'>)</font>;

                <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>fright[<font color='#979000'>3</font>] <font color='#5555FF'>&gt;</font><font color='#5555FF'>=</font> in_img.<font color='#BB00BB'>nc</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>
                    <font color='#0000FF'>break</font>;
                simd4f <font color='#BB00BB'>tl</font><font face='Lucida Console'>(</font>in_img[top][fleft[<font color='#979000'>0</font>]],     in_img[top][fleft[<font color='#979000'>1</font>]],     in_img[top][fleft[<font color='#979000'>2</font>]],     in_img[top][fleft[<font color='#979000'>3</font>]]<font face='Lucida Console'>)</font>;
                simd4f <font color='#BB00BB'>tr</font><font face='Lucida Console'>(</font>in_img[top][fright[<font color='#979000'>0</font>]],    in_img[top][fright[<font color='#979000'>1</font>]],    in_img[top][fright[<font color='#979000'>2</font>]],    in_img[top][fright[<font color='#979000'>3</font>]]<font face='Lucida Console'>)</font>;
                simd4f <font color='#BB00BB'>bl</font><font face='Lucida Console'>(</font>in_img[bottom][fleft[<font color='#979000'>0</font>]],  in_img[bottom][fleft[<font color='#979000'>1</font>]],  in_img[bottom][fleft[<font color='#979000'>2</font>]],  in_img[bottom][fleft[<font color='#979000'>3</font>]]<font face='Lucida Console'>)</font>;
                simd4f <font color='#BB00BB'>br</font><font face='Lucida Console'>(</font>in_img[bottom][fright[<font color='#979000'>0</font>]], in_img[bottom][fright[<font color='#979000'>1</font>]], in_img[bottom][fright[<font color='#979000'>2</font>]], in_img[bottom][fright[<font color='#979000'>3</font>]]<font face='Lucida Console'>)</font>;

                simd4i out <font color='#5555FF'>=</font> <font color='#BB00BB'>simd4i</font><font face='Lucida Console'>(</font>tlf<font color='#5555FF'>*</font>tl <font color='#5555FF'>+</font> trf<font color='#5555FF'>*</font>tr <font color='#5555FF'>+</font> blf<font color='#5555FF'>*</font>bl <font color='#5555FF'>+</font> brf<font color='#5555FF'>*</font>br<font face='Lucida Console'>)</font>;
                int32 fout[<font color='#979000'>4</font>];
                out.<font color='#BB00BB'>store</font><font face='Lucida Console'>(</font>fout<font face='Lucida Console'>)</font>;

                out_img[r][c]   <font color='#5555FF'>=</font> <font color='#0000FF'>static_cast</font><font color='#5555FF'>&lt;</font>T<font color='#5555FF'>&gt;</font><font face='Lucida Console'>(</font>fout[<font color='#979000'>0</font>]<font face='Lucida Console'>)</font>;
                out_img[r][c<font color='#5555FF'>+</font><font color='#979000'>1</font>] <font color='#5555FF'>=</font> <font color='#0000FF'>static_cast</font><font color='#5555FF'>&lt;</font>T<font color='#5555FF'>&gt;</font><font face='Lucida Console'>(</font>fout[<font color='#979000'>1</font>]<font face='Lucida Console'>)</font>;
                out_img[r][c<font color='#5555FF'>+</font><font color='#979000'>2</font>] <font color='#5555FF'>=</font> <font color='#0000FF'>static_cast</font><font color='#5555FF'>&lt;</font>T<font color='#5555FF'>&gt;</font><font face='Lucida Console'>(</font>fout[<font color='#979000'>2</font>]<font face='Lucida Console'>)</font>;
                out_img[r][c<font color='#5555FF'>+</font><font color='#979000'>3</font>] <font color='#5555FF'>=</font> <font color='#0000FF'>static_cast</font><font color='#5555FF'>&lt;</font>T<font color='#5555FF'>&gt;</font><font face='Lucida Console'>(</font>fout[<font color='#979000'>3</font>]<font face='Lucida Console'>)</font>;
            <b>}</b>
            x <font color='#5555FF'>=</font> <font color='#5555FF'>-</font>x_scale <font color='#5555FF'>+</font> c<font color='#5555FF'>*</font>x_scale;
            <font color='#0000FF'>for</font> <font face='Lucida Console'>(</font>; c <font color='#5555FF'>&lt;</font> out_img.<font color='#BB00BB'>nc</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>; <font color='#5555FF'>+</font><font color='#5555FF'>+</font>c<font face='Lucida Console'>)</font>
            <b>{</b>
                x <font color='#5555FF'>+</font><font color='#5555FF'>=</font> x_scale;
                <font color='#0000FF'>const</font> <font color='#0000FF'><u>long</u></font> left   <font color='#5555FF'>=</font> <font color='#0000FF'>static_cast</font><font color='#5555FF'>&lt;</font><font color='#0000FF'><u>long</u></font><font color='#5555FF'>&gt;</font><font face='Lucida Console'>(</font>std::<font color='#BB00BB'>floor</font><font face='Lucida Console'>(</font>x<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
                <font color='#0000FF'>const</font> <font color='#0000FF'><u>long</u></font> right  <font color='#5555FF'>=</font> std::<font color='#BB00BB'>min</font><font face='Lucida Console'>(</font>left<font color='#5555FF'>+</font><font color='#979000'>1</font>, in_img.<font color='#BB00BB'>nc</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font color='#5555FF'>-</font><font color='#979000'>1</font><font face='Lucida Console'>)</font>;
                <font color='#0000FF'>const</font> <font color='#0000FF'><u>float</u></font> lr_frac <font color='#5555FF'>=</font> x <font color='#5555FF'>-</font> left;

                <font color='#0000FF'><u>float</u></font> tl <font color='#5555FF'>=</font> <font color='#979000'>0</font>, tr <font color='#5555FF'>=</font> <font color='#979000'>0</font>, bl <font color='#5555FF'>=</font> <font color='#979000'>0</font>, br <font color='#5555FF'>=</font> <font color='#979000'>0</font>;

                <font color='#BB00BB'>assign_pixel</font><font face='Lucida Console'>(</font>tl, in_img[top][left]<font face='Lucida Console'>)</font>;
                <font color='#BB00BB'>assign_pixel</font><font face='Lucida Console'>(</font>tr, in_img[top][right]<font face='Lucida Console'>)</font>;
                <font color='#BB00BB'>assign_pixel</font><font face='Lucida Console'>(</font>bl, in_img[bottom][left]<font face='Lucida Console'>)</font>;
                <font color='#BB00BB'>assign_pixel</font><font face='Lucida Console'>(</font>br, in_img[bottom][right]<font face='Lucida Console'>)</font>;

                <font color='#0000FF'><u>float</u></font> temp <font color='#5555FF'>=</font> <font face='Lucida Console'>(</font><font color='#979000'>1</font><font color='#5555FF'>-</font>tb_frac<font face='Lucida Console'>)</font><font color='#5555FF'>*</font><font face='Lucida Console'>(</font><font face='Lucida Console'>(</font><font color='#979000'>1</font><font color='#5555FF'>-</font>lr_frac<font face='Lucida Console'>)</font><font color='#5555FF'>*</font>tl <font color='#5555FF'>+</font> lr_frac<font color='#5555FF'>*</font>tr<font face='Lucida Console'>)</font> <font color='#5555FF'>+</font> 
                    tb_frac<font color='#5555FF'>*</font><font face='Lucida Console'>(</font><font face='Lucida Console'>(</font><font color='#979000'>1</font><font color='#5555FF'>-</font>lr_frac<font face='Lucida Console'>)</font><font color='#5555FF'>*</font>bl <font color='#5555FF'>+</font> lr_frac<font color='#5555FF'>*</font>br<font face='Lucida Console'>)</font>;

                <font color='#BB00BB'>assign_pixel</font><font face='Lucida Console'>(</font>out_img[r][c], temp<font face='Lucida Console'>)</font>;
            <b>}</b>
        <b>}</b>
    <b>}</b>

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font>
        <font color='#0000FF'>typename</font> image_type
        <font color='#5555FF'>&gt;</font>
    <font color='#0000FF'>typename</font> enable_if<font color='#5555FF'>&lt;</font>is_rgb_image<font color='#5555FF'>&lt;</font>image_type<font color='#5555FF'>&gt;</font> <font color='#5555FF'>&gt;</font>::type <b><a name='resize_image'></a>resize_image</b> <font face='Lucida Console'>(</font>
        <font color='#0000FF'>const</font> image_type<font color='#5555FF'>&amp;</font> in_img_,
        image_type<font color='#5555FF'>&amp;</font> out_img_,
        interpolate_bilinear
    <font face='Lucida Console'>)</font>
    <b>{</b>
        <font color='#009900'>// make sure requires clause is not broken
</font>        <font color='#BB00BB'>DLIB_ASSERT</font><font face='Lucida Console'>(</font> <font color='#BB00BB'>is_same_object</font><font face='Lucida Console'>(</font>in_img_, out_img_<font face='Lucida Console'>)</font> <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>false</font> ,
            "<font color='#CC0000'>\t void resize_image()</font>"
            <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t Invalid inputs were given to this function.</font>"
            <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t is_same_object(in_img_, out_img_):  </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> <font color='#BB00BB'>is_same_object</font><font face='Lucida Console'>(</font>in_img_, out_img_<font face='Lucida Console'>)</font>
            <font face='Lucida Console'>)</font>;

        const_image_view<font color='#5555FF'>&lt;</font>image_type<font color='#5555FF'>&gt;</font> <font color='#BB00BB'>in_img</font><font face='Lucida Console'>(</font>in_img_<font face='Lucida Console'>)</font>;
        image_view<font color='#5555FF'>&lt;</font>image_type<font color='#5555FF'>&gt;</font> <font color='#BB00BB'>out_img</font><font face='Lucida Console'>(</font>out_img_<font face='Lucida Console'>)</font>;

        <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>out_img.<font color='#BB00BB'>nr</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>&lt;</font><font color='#5555FF'>=</font> <font color='#979000'>1</font> <font color='#5555FF'>|</font><font color='#5555FF'>|</font> out_img.<font color='#BB00BB'>nc</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>&lt;</font><font color='#5555FF'>=</font> <font color='#979000'>1</font><font face='Lucida Console'>)</font>
        <b>{</b>
            <font color='#BB00BB'>assign_all_pixels</font><font face='Lucida Console'>(</font>out_img, <font color='#979000'>0</font><font face='Lucida Console'>)</font>;
            <font color='#0000FF'>return</font>;
        <b>}</b>


        <font color='#0000FF'>typedef</font> <font color='#0000FF'>typename</font> image_traits<font color='#5555FF'>&lt;</font>image_type<font color='#5555FF'>&gt;</font>::pixel_type T;
        <font color='#0000FF'>const</font> <font color='#0000FF'><u>double</u></font> x_scale <font color='#5555FF'>=</font> <font face='Lucida Console'>(</font>in_img.<font color='#BB00BB'>nc</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font color='#5555FF'>-</font><font color='#979000'>1</font><font face='Lucida Console'>)</font><font color='#5555FF'>/</font><font face='Lucida Console'>(</font><font color='#0000FF'><u>double</u></font><font face='Lucida Console'>)</font>std::max<font color='#5555FF'>&lt;</font><font color='#0000FF'><u>long</u></font><font color='#5555FF'>&gt;</font><font face='Lucida Console'>(</font><font face='Lucida Console'>(</font>out_img.<font color='#BB00BB'>nc</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font color='#5555FF'>-</font><font color='#979000'>1</font><font face='Lucida Console'>)</font>,<font color='#979000'>1</font><font face='Lucida Console'>)</font>;
        <font color='#0000FF'>const</font> <font color='#0000FF'><u>double</u></font> y_scale <font color='#5555FF'>=</font> <font face='Lucida Console'>(</font>in_img.<font color='#BB00BB'>nr</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font color='#5555FF'>-</font><font color='#979000'>1</font><font face='Lucida Console'>)</font><font color='#5555FF'>/</font><font face='Lucida Console'>(</font><font color='#0000FF'><u>double</u></font><font face='Lucida Console'>)</font>std::max<font color='#5555FF'>&lt;</font><font color='#0000FF'><u>long</u></font><font color='#5555FF'>&gt;</font><font face='Lucida Console'>(</font><font face='Lucida Console'>(</font>out_img.<font color='#BB00BB'>nr</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font color='#5555FF'>-</font><font color='#979000'>1</font><font face='Lucida Console'>)</font>,<font color='#979000'>1</font><font face='Lucida Console'>)</font>;
        <font color='#0000FF'><u>double</u></font> y <font color='#5555FF'>=</font> <font color='#5555FF'>-</font>y_scale;
        <font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>long</u></font> r <font color='#5555FF'>=</font> <font color='#979000'>0</font>; r <font color='#5555FF'>&lt;</font> out_img.<font color='#BB00BB'>nr</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>; <font color='#5555FF'>+</font><font color='#5555FF'>+</font>r<font face='Lucida Console'>)</font>
        <b>{</b>
            y <font color='#5555FF'>+</font><font color='#5555FF'>=</font> y_scale;
            <font color='#0000FF'>const</font> <font color='#0000FF'><u>long</u></font> top    <font color='#5555FF'>=</font> <font color='#0000FF'>static_cast</font><font color='#5555FF'>&lt;</font><font color='#0000FF'><u>long</u></font><font color='#5555FF'>&gt;</font><font face='Lucida Console'>(</font>std::<font color='#BB00BB'>floor</font><font face='Lucida Console'>(</font>y<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
            <font color='#0000FF'>const</font> <font color='#0000FF'><u>long</u></font> bottom <font color='#5555FF'>=</font> std::<font color='#BB00BB'>min</font><font face='Lucida Console'>(</font>top<font color='#5555FF'>+</font><font color='#979000'>1</font>, in_img.<font color='#BB00BB'>nr</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font color='#5555FF'>-</font><font color='#979000'>1</font><font face='Lucida Console'>)</font>;
            <font color='#0000FF'>const</font> <font color='#0000FF'><u>double</u></font> tb_frac <font color='#5555FF'>=</font> y <font color='#5555FF'>-</font> top;
            <font color='#0000FF'><u>double</u></font> x <font color='#5555FF'>=</font> <font color='#5555FF'>-</font><font color='#979000'>4</font><font color='#5555FF'>*</font>x_scale;

            <font color='#0000FF'>const</font> simd4f _tb_frac <font color='#5555FF'>=</font> tb_frac;
            <font color='#0000FF'>const</font> simd4f _inv_tb_frac <font color='#5555FF'>=</font> <font color='#979000'>1</font><font color='#5555FF'>-</font>tb_frac;
            <font color='#0000FF'>const</font> simd4f _x_scale <font color='#5555FF'>=</font> <font color='#979000'>4</font><font color='#5555FF'>*</font>x_scale;
            simd4f <font color='#BB00BB'>_x</font><font face='Lucida Console'>(</font>x, x<font color='#5555FF'>+</font>x_scale, x<font color='#5555FF'>+</font><font color='#979000'>2</font><font color='#5555FF'>*</font>x_scale, x<font color='#5555FF'>+</font><font color='#979000'>3</font><font color='#5555FF'>*</font>x_scale<font face='Lucida Console'>)</font>;
            <font color='#0000FF'><u>long</u></font> c <font color='#5555FF'>=</font> <font color='#979000'>0</font>;
            <font color='#0000FF'>for</font> <font face='Lucida Console'>(</font>;; c<font color='#5555FF'>+</font><font color='#5555FF'>=</font><font color='#979000'>4</font><font face='Lucida Console'>)</font>
            <b>{</b>
                _x <font color='#5555FF'>+</font><font color='#5555FF'>=</font> _x_scale;
                simd4i left <font color='#5555FF'>=</font> <font color='#BB00BB'>simd4i</font><font face='Lucida Console'>(</font>_x<font face='Lucida Console'>)</font>;
                simd4f lr_frac <font color='#5555FF'>=</font> _x<font color='#5555FF'>-</font>left;
                simd4f _inv_lr_frac <font color='#5555FF'>=</font> <font color='#979000'>1</font><font color='#5555FF'>-</font>lr_frac; 
                simd4i right <font color='#5555FF'>=</font> left<font color='#5555FF'>+</font><font color='#979000'>1</font>;

                simd4f tlf <font color='#5555FF'>=</font> _inv_tb_frac<font color='#5555FF'>*</font>_inv_lr_frac;
                simd4f trf <font color='#5555FF'>=</font> _inv_tb_frac<font color='#5555FF'>*</font>lr_frac;
                simd4f blf <font color='#5555FF'>=</font> _tb_frac<font color='#5555FF'>*</font>_inv_lr_frac;
                simd4f brf <font color='#5555FF'>=</font> _tb_frac<font color='#5555FF'>*</font>lr_frac;

                int32 fleft[<font color='#979000'>4</font>];
                int32 fright[<font color='#979000'>4</font>];
                left.<font color='#BB00BB'>store</font><font face='Lucida Console'>(</font>fleft<font face='Lucida Console'>)</font>;
                right.<font color='#BB00BB'>store</font><font face='Lucida Console'>(</font>fright<font face='Lucida Console'>)</font>;

                <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>fright[<font color='#979000'>3</font>] <font color='#5555FF'>&gt;</font><font color='#5555FF'>=</font> in_img.<font color='#BB00BB'>nc</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>
                    <font color='#0000FF'>break</font>;
                simd4f <font color='#BB00BB'>tl</font><font face='Lucida Console'>(</font>in_img[top][fleft[<font color='#979000'>0</font>]].red,     in_img[top][fleft[<font color='#979000'>1</font>]].red,     in_img[top][fleft[<font color='#979000'>2</font>]].red,     in_img[top][fleft[<font color='#979000'>3</font>]].red<font face='Lucida Console'>)</font>;
                simd4f <font color='#BB00BB'>tr</font><font face='Lucida Console'>(</font>in_img[top][fright[<font color='#979000'>0</font>]].red,    in_img[top][fright[<font color='#979000'>1</font>]].red,    in_img[top][fright[<font color='#979000'>2</font>]].red,    in_img[top][fright[<font color='#979000'>3</font>]].red<font face='Lucida Console'>)</font>;
                simd4f <font color='#BB00BB'>bl</font><font face='Lucida Console'>(</font>in_img[bottom][fleft[<font color='#979000'>0</font>]].red,  in_img[bottom][fleft[<font color='#979000'>1</font>]].red,  in_img[bottom][fleft[<font color='#979000'>2</font>]].red,  in_img[bottom][fleft[<font color='#979000'>3</font>]].red<font face='Lucida Console'>)</font>;
                simd4f <font color='#BB00BB'>br</font><font face='Lucida Console'>(</font>in_img[bottom][fright[<font color='#979000'>0</font>]].red, in_img[bottom][fright[<font color='#979000'>1</font>]].red, in_img[bottom][fright[<font color='#979000'>2</font>]].red, in_img[bottom][fright[<font color='#979000'>3</font>]].red<font face='Lucida Console'>)</font>;

                simd4i out <font color='#5555FF'>=</font> <font color='#BB00BB'>simd4i</font><font face='Lucida Console'>(</font>tlf<font color='#5555FF'>*</font>tl <font color='#5555FF'>+</font> trf<font color='#5555FF'>*</font>tr <font color='#5555FF'>+</font> blf<font color='#5555FF'>*</font>bl <font color='#5555FF'>+</font> brf<font color='#5555FF'>*</font>br<font face='Lucida Console'>)</font>;
                int32 fout[<font color='#979000'>4</font>];
                out.<font color='#BB00BB'>store</font><font face='Lucida Console'>(</font>fout<font face='Lucida Console'>)</font>;

                out_img[r][c].red   <font color='#5555FF'>=</font> <font color='#0000FF'>static_cast</font><font color='#5555FF'>&lt;</font><font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>char</u></font><font color='#5555FF'>&gt;</font><font face='Lucida Console'>(</font>fout[<font color='#979000'>0</font>]<font face='Lucida Console'>)</font>;
                out_img[r][c<font color='#5555FF'>+</font><font color='#979000'>1</font>].red <font color='#5555FF'>=</font> <font color='#0000FF'>static_cast</font><font color='#5555FF'>&lt;</font><font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>char</u></font><font color='#5555FF'>&gt;</font><font face='Lucida Console'>(</font>fout[<font color='#979000'>1</font>]<font face='Lucida Console'>)</font>;
                out_img[r][c<font color='#5555FF'>+</font><font color='#979000'>2</font>].red <font color='#5555FF'>=</font> <font color='#0000FF'>static_cast</font><font color='#5555FF'>&lt;</font><font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>char</u></font><font color='#5555FF'>&gt;</font><font face='Lucida Console'>(</font>fout[<font color='#979000'>2</font>]<font face='Lucida Console'>)</font>;
                out_img[r][c<font color='#5555FF'>+</font><font color='#979000'>3</font>].red <font color='#5555FF'>=</font> <font color='#0000FF'>static_cast</font><font color='#5555FF'>&lt;</font><font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>char</u></font><font color='#5555FF'>&gt;</font><font face='Lucida Console'>(</font>fout[<font color='#979000'>3</font>]<font face='Lucida Console'>)</font>;


                tl <font color='#5555FF'>=</font> <font color='#BB00BB'>simd4f</font><font face='Lucida Console'>(</font>in_img[top][fleft[<font color='#979000'>0</font>]].green,    in_img[top][fleft[<font color='#979000'>1</font>]].green,    in_img[top][fleft[<font color='#979000'>2</font>]].green,    in_img[top][fleft[<font color='#979000'>3</font>]].green<font face='Lucida Console'>)</font>;
                tr <font color='#5555FF'>=</font> <font color='#BB00BB'>simd4f</font><font face='Lucida Console'>(</font>in_img[top][fright[<font color='#979000'>0</font>]].green,   in_img[top][fright[<font color='#979000'>1</font>]].green,   in_img[top][fright[<font color='#979000'>2</font>]].green,   in_img[top][fright[<font color='#979000'>3</font>]].green<font face='Lucida Console'>)</font>;
                bl <font color='#5555FF'>=</font> <font color='#BB00BB'>simd4f</font><font face='Lucida Console'>(</font>in_img[bottom][fleft[<font color='#979000'>0</font>]].green, in_img[bottom][fleft[<font color='#979000'>1</font>]].green, in_img[bottom][fleft[<font color='#979000'>2</font>]].green, in_img[bottom][fleft[<font color='#979000'>3</font>]].green<font face='Lucida Console'>)</font>;
                br <font color='#5555FF'>=</font> <font color='#BB00BB'>simd4f</font><font face='Lucida Console'>(</font>in_img[bottom][fright[<font color='#979000'>0</font>]].green, in_img[bottom][fright[<font color='#979000'>1</font>]].green, in_img[bottom][fright[<font color='#979000'>2</font>]].green, in_img[bottom][fright[<font color='#979000'>3</font>]].green<font face='Lucida Console'>)</font>;
                out <font color='#5555FF'>=</font> <font color='#BB00BB'>simd4i</font><font face='Lucida Console'>(</font>tlf<font color='#5555FF'>*</font>tl <font color='#5555FF'>+</font> trf<font color='#5555FF'>*</font>tr <font color='#5555FF'>+</font> blf<font color='#5555FF'>*</font>bl <font color='#5555FF'>+</font> brf<font color='#5555FF'>*</font>br<font face='Lucida Console'>)</font>;
                out.<font color='#BB00BB'>store</font><font face='Lucida Console'>(</font>fout<font face='Lucida Console'>)</font>;
                out_img[r][c].green   <font color='#5555FF'>=</font> <font color='#0000FF'>static_cast</font><font color='#5555FF'>&lt;</font><font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>char</u></font><font color='#5555FF'>&gt;</font><font face='Lucida Console'>(</font>fout[<font color='#979000'>0</font>]<font face='Lucida Console'>)</font>;
                out_img[r][c<font color='#5555FF'>+</font><font color='#979000'>1</font>].green <font color='#5555FF'>=</font> <font color='#0000FF'>static_cast</font><font color='#5555FF'>&lt;</font><font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>char</u></font><font color='#5555FF'>&gt;</font><font face='Lucida Console'>(</font>fout[<font color='#979000'>1</font>]<font face='Lucida Console'>)</font>;
                out_img[r][c<font color='#5555FF'>+</font><font color='#979000'>2</font>].green <font color='#5555FF'>=</font> <font color='#0000FF'>static_cast</font><font color='#5555FF'>&lt;</font><font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>char</u></font><font color='#5555FF'>&gt;</font><font face='Lucida Console'>(</font>fout[<font color='#979000'>2</font>]<font face='Lucida Console'>)</font>;
                out_img[r][c<font color='#5555FF'>+</font><font color='#979000'>3</font>].green <font color='#5555FF'>=</font> <font color='#0000FF'>static_cast</font><font color='#5555FF'>&lt;</font><font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>char</u></font><font color='#5555FF'>&gt;</font><font face='Lucida Console'>(</font>fout[<font color='#979000'>3</font>]<font face='Lucida Console'>)</font>;


                tl <font color='#5555FF'>=</font> <font color='#BB00BB'>simd4f</font><font face='Lucida Console'>(</font>in_img[top][fleft[<font color='#979000'>0</font>]].blue,     in_img[top][fleft[<font color='#979000'>1</font>]].blue,     in_img[top][fleft[<font color='#979000'>2</font>]].blue,     in_img[top][fleft[<font color='#979000'>3</font>]].blue<font face='Lucida Console'>)</font>;
                tr <font color='#5555FF'>=</font> <font color='#BB00BB'>simd4f</font><font face='Lucida Console'>(</font>in_img[top][fright[<font color='#979000'>0</font>]].blue,    in_img[top][fright[<font color='#979000'>1</font>]].blue,    in_img[top][fright[<font color='#979000'>2</font>]].blue,    in_img[top][fright[<font color='#979000'>3</font>]].blue<font face='Lucida Console'>)</font>;
                bl <font color='#5555FF'>=</font> <font color='#BB00BB'>simd4f</font><font face='Lucida Console'>(</font>in_img[bottom][fleft[<font color='#979000'>0</font>]].blue,  in_img[bottom][fleft[<font color='#979000'>1</font>]].blue,  in_img[bottom][fleft[<font color='#979000'>2</font>]].blue,  in_img[bottom][fleft[<font color='#979000'>3</font>]].blue<font face='Lucida Console'>)</font>;
                br <font color='#5555FF'>=</font> <font color='#BB00BB'>simd4f</font><font face='Lucida Console'>(</font>in_img[bottom][fright[<font color='#979000'>0</font>]].blue, in_img[bottom][fright[<font color='#979000'>1</font>]].blue, in_img[bottom][fright[<font color='#979000'>2</font>]].blue, in_img[bottom][fright[<font color='#979000'>3</font>]].blue<font face='Lucida Console'>)</font>;
                out <font color='#5555FF'>=</font> <font color='#BB00BB'>simd4i</font><font face='Lucida Console'>(</font>tlf<font color='#5555FF'>*</font>tl <font color='#5555FF'>+</font> trf<font color='#5555FF'>*</font>tr <font color='#5555FF'>+</font> blf<font color='#5555FF'>*</font>bl <font color='#5555FF'>+</font> brf<font color='#5555FF'>*</font>br<font face='Lucida Console'>)</font>;
                out.<font color='#BB00BB'>store</font><font face='Lucida Console'>(</font>fout<font face='Lucida Console'>)</font>;
                out_img[r][c].blue   <font color='#5555FF'>=</font> <font color='#0000FF'>static_cast</font><font color='#5555FF'>&lt;</font><font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>char</u></font><font color='#5555FF'>&gt;</font><font face='Lucida Console'>(</font>fout[<font color='#979000'>0</font>]<font face='Lucida Console'>)</font>;
                out_img[r][c<font color='#5555FF'>+</font><font color='#979000'>1</font>].blue <font color='#5555FF'>=</font> <font color='#0000FF'>static_cast</font><font color='#5555FF'>&lt;</font><font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>char</u></font><font color='#5555FF'>&gt;</font><font face='Lucida Console'>(</font>fout[<font color='#979000'>1</font>]<font face='Lucida Console'>)</font>;
                out_img[r][c<font color='#5555FF'>+</font><font color='#979000'>2</font>].blue <font color='#5555FF'>=</font> <font color='#0000FF'>static_cast</font><font color='#5555FF'>&lt;</font><font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>char</u></font><font color='#5555FF'>&gt;</font><font face='Lucida Console'>(</font>fout[<font color='#979000'>2</font>]<font face='Lucida Console'>)</font>;
                out_img[r][c<font color='#5555FF'>+</font><font color='#979000'>3</font>].blue <font color='#5555FF'>=</font> <font color='#0000FF'>static_cast</font><font color='#5555FF'>&lt;</font><font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>char</u></font><font color='#5555FF'>&gt;</font><font face='Lucida Console'>(</font>fout[<font color='#979000'>3</font>]<font face='Lucida Console'>)</font>;
            <b>}</b>
            x <font color='#5555FF'>=</font> <font color='#5555FF'>-</font>x_scale <font color='#5555FF'>+</font> c<font color='#5555FF'>*</font>x_scale;
            <font color='#0000FF'>for</font> <font face='Lucida Console'>(</font>; c <font color='#5555FF'>&lt;</font> out_img.<font color='#BB00BB'>nc</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>; <font color='#5555FF'>+</font><font color='#5555FF'>+</font>c<font face='Lucida Console'>)</font>
            <b>{</b>
                x <font color='#5555FF'>+</font><font color='#5555FF'>=</font> x_scale;
                <font color='#0000FF'>const</font> <font color='#0000FF'><u>long</u></font> left   <font color='#5555FF'>=</font> <font color='#0000FF'>static_cast</font><font color='#5555FF'>&lt;</font><font color='#0000FF'><u>long</u></font><font color='#5555FF'>&gt;</font><font face='Lucida Console'>(</font>std::<font color='#BB00BB'>floor</font><font face='Lucida Console'>(</font>x<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
                <font color='#0000FF'>const</font> <font color='#0000FF'><u>long</u></font> right  <font color='#5555FF'>=</font> std::<font color='#BB00BB'>min</font><font face='Lucida Console'>(</font>left<font color='#5555FF'>+</font><font color='#979000'>1</font>, in_img.<font color='#BB00BB'>nc</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font color='#5555FF'>-</font><font color='#979000'>1</font><font face='Lucida Console'>)</font>;
                <font color='#0000FF'>const</font> <font color='#0000FF'><u>double</u></font> lr_frac <font color='#5555FF'>=</font> x <font color='#5555FF'>-</font> left;

                <font color='#0000FF'>const</font> T tl <font color='#5555FF'>=</font> in_img[top][left];
                <font color='#0000FF'>const</font> T tr <font color='#5555FF'>=</font> in_img[top][right];
                <font color='#0000FF'>const</font> T bl <font color='#5555FF'>=</font> in_img[bottom][left];
                <font color='#0000FF'>const</font> T br <font color='#5555FF'>=</font> in_img[bottom][right];

                T temp;
                <font color='#BB00BB'>assign_pixel</font><font face='Lucida Console'>(</font>temp, <font color='#979000'>0</font><font face='Lucida Console'>)</font>;
                <font color='#BB00BB'>vector_to_pixel</font><font face='Lucida Console'>(</font>temp, 
                    <font face='Lucida Console'>(</font><font color='#979000'>1</font><font color='#5555FF'>-</font>tb_frac<font face='Lucida Console'>)</font><font color='#5555FF'>*</font><font face='Lucida Console'>(</font><font face='Lucida Console'>(</font><font color='#979000'>1</font><font color='#5555FF'>-</font>lr_frac<font face='Lucida Console'>)</font><font color='#5555FF'>*</font>pixel_to_vector<font color='#5555FF'>&lt;</font><font color='#0000FF'><u>double</u></font><font color='#5555FF'>&gt;</font><font face='Lucida Console'>(</font>tl<font face='Lucida Console'>)</font> <font color='#5555FF'>+</font> lr_frac<font color='#5555FF'>*</font>pixel_to_vector<font color='#5555FF'>&lt;</font><font color='#0000FF'><u>double</u></font><font color='#5555FF'>&gt;</font><font face='Lucida Console'>(</font>tr<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font> <font color='#5555FF'>+</font> 
                    tb_frac<font color='#5555FF'>*</font><font face='Lucida Console'>(</font><font face='Lucida Console'>(</font><font color='#979000'>1</font><font color='#5555FF'>-</font>lr_frac<font face='Lucida Console'>)</font><font color='#5555FF'>*</font>pixel_to_vector<font color='#5555FF'>&lt;</font><font color='#0000FF'><u>double</u></font><font color='#5555FF'>&gt;</font><font face='Lucida Console'>(</font>bl<font face='Lucida Console'>)</font> <font color='#5555FF'>+</font> lr_frac<font color='#5555FF'>*</font>pixel_to_vector<font color='#5555FF'>&lt;</font><font color='#0000FF'><u>double</u></font><font color='#5555FF'>&gt;</font><font face='Lucida Console'>(</font>br<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
                <font color='#BB00BB'>assign_pixel</font><font face='Lucida Console'>(</font>out_img[r][c], temp<font face='Lucida Console'>)</font>;
            <b>}</b>
        <b>}</b>
    <b>}</b>

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font>
        <font color='#0000FF'>typename</font> image_type1,
        <font color='#0000FF'>typename</font> image_type2
        <font color='#5555FF'>&gt;</font>
    <font color='#0000FF'><u>void</u></font> <b><a name='resize_image'></a>resize_image</b> <font face='Lucida Console'>(</font>
        <font color='#0000FF'>const</font> image_type1<font color='#5555FF'>&amp;</font> in_img,
        image_type2<font color='#5555FF'>&amp;</font> out_img
    <font face='Lucida Console'>)</font>
    <b>{</b>
        <font color='#009900'>// make sure requires clause is not broken
</font>        <font color='#BB00BB'>DLIB_ASSERT</font><font face='Lucida Console'>(</font> <font color='#BB00BB'>is_same_object</font><font face='Lucida Console'>(</font>in_img, out_img<font face='Lucida Console'>)</font> <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>false</font> ,
            "<font color='#CC0000'>\t void resize_image()</font>"
            <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t Invalid inputs were given to this function.</font>"
            <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t is_same_object(in_img, out_img):  </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> <font color='#BB00BB'>is_same_object</font><font face='Lucida Console'>(</font>in_img, out_img<font face='Lucida Console'>)</font>
            <font face='Lucida Console'>)</font>;

        <font color='#BB00BB'>resize_image</font><font face='Lucida Console'>(</font>in_img, out_img, <font color='#BB00BB'>interpolate_bilinear</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
    <b>}</b>

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font>
        <font color='#0000FF'>typename</font> image_type1,
        <font color='#0000FF'>typename</font> image_type2
        <font color='#5555FF'>&gt;</font>
    point_transform_affine <b><a name='flip_image_left_right'></a>flip_image_left_right</b> <font face='Lucida Console'>(</font>
        <font color='#0000FF'>const</font> image_type1<font color='#5555FF'>&amp;</font> in_img,
        image_type2<font color='#5555FF'>&amp;</font> out_img
    <font face='Lucida Console'>)</font>
    <b>{</b>
        <font color='#009900'>// make sure requires clause is not broken
</font>        <font color='#BB00BB'>DLIB_ASSERT</font><font face='Lucida Console'>(</font> <font color='#BB00BB'>is_same_object</font><font face='Lucida Console'>(</font>in_img, out_img<font face='Lucida Console'>)</font> <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>false</font> ,
            "<font color='#CC0000'>\t void flip_image_left_right()</font>"
            <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t Invalid inputs were given to this function.</font>"
            <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t is_same_object(in_img, out_img):  </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> <font color='#BB00BB'>is_same_object</font><font face='Lucida Console'>(</font>in_img, out_img<font face='Lucida Console'>)</font>
            <font face='Lucida Console'>)</font>;

        <font color='#BB00BB'>assign_image</font><font face='Lucida Console'>(</font>out_img, <font color='#BB00BB'>fliplr</font><font face='Lucida Console'>(</font><font color='#BB00BB'>mat</font><font face='Lucida Console'>(</font>in_img<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
        std::vector<font color='#5555FF'>&lt;</font>dlib::vector<font color='#5555FF'>&lt;</font><font color='#0000FF'><u>double</u></font>,<font color='#979000'>2</font><font color='#5555FF'>&gt;</font> <font color='#5555FF'>&gt;</font> from, to;
        rectangle r <font color='#5555FF'>=</font> <font color='#BB00BB'>get_rect</font><font face='Lucida Console'>(</font>in_img<font face='Lucida Console'>)</font>;
        from.<font color='#BB00BB'>push_back</font><font face='Lucida Console'>(</font>r.<font color='#BB00BB'>tl_corner</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>; to.<font color='#BB00BB'>push_back</font><font face='Lucida Console'>(</font>r.<font color='#BB00BB'>tr_corner</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
        from.<font color='#BB00BB'>push_back</font><font face='Lucida Console'>(</font>r.<font color='#BB00BB'>bl_corner</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>; to.<font color='#BB00BB'>push_back</font><font face='Lucida Console'>(</font>r.<font color='#BB00BB'>br_corner</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
        from.<font color='#BB00BB'>push_back</font><font face='Lucida Console'>(</font>r.<font color='#BB00BB'>tr_corner</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>; to.<font color='#BB00BB'>push_back</font><font face='Lucida Console'>(</font>r.<font color='#BB00BB'>tl_corner</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
        from.<font color='#BB00BB'>push_back</font><font face='Lucida Console'>(</font>r.<font color='#BB00BB'>br_corner</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>; to.<font color='#BB00BB'>push_back</font><font face='Lucida Console'>(</font>r.<font color='#BB00BB'>bl_corner</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
        <font color='#0000FF'>return</font> <font color='#BB00BB'>find_affine_transform</font><font face='Lucida Console'>(</font>from,to<font face='Lucida Console'>)</font>;
    <b>}</b>

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font>
        <font color='#0000FF'>typename</font> image_type1,
        <font color='#0000FF'>typename</font> image_type2
        <font color='#5555FF'>&gt;</font>
    <font color='#0000FF'><u>void</u></font> <b><a name='flip_image_up_down'></a>flip_image_up_down</b> <font face='Lucida Console'>(</font>
        <font color='#0000FF'>const</font> image_type1<font color='#5555FF'>&amp;</font> in_img,
        image_type2<font color='#5555FF'>&amp;</font> out_img
    <font face='Lucida Console'>)</font>
    <b>{</b>
        <font color='#009900'>// make sure requires clause is not broken
</font>        <font color='#BB00BB'>DLIB_ASSERT</font><font face='Lucida Console'>(</font> <font color='#BB00BB'>is_same_object</font><font face='Lucida Console'>(</font>in_img, out_img<font face='Lucida Console'>)</font> <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>false</font> ,
            "<font color='#CC0000'>\t void flip_image_up_down()</font>"
            <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t Invalid inputs were given to this function.</font>"
            <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t is_same_object(in_img, out_img):  </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> <font color='#BB00BB'>is_same_object</font><font face='Lucida Console'>(</font>in_img, out_img<font face='Lucida Console'>)</font>
            <font face='Lucida Console'>)</font>;

        <font color='#BB00BB'>assign_image</font><font face='Lucida Console'>(</font>out_img, <font color='#BB00BB'>flipud</font><font face='Lucida Console'>(</font><font color='#BB00BB'>mat</font><font face='Lucida Console'>(</font>in_img<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
    <b>}</b>

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
    <font color='#0000FF'>namespace</font> impl
    <b>{</b>
        <font color='#0000FF'>inline</font> rectangle <b><a name='flip_rect_left_right'></a>flip_rect_left_right</b> <font face='Lucida Console'>(</font>
            <font color='#0000FF'>const</font> rectangle<font color='#5555FF'>&amp;</font> rect,
            <font color='#0000FF'>const</font> rectangle<font color='#5555FF'>&amp;</font> window 
        <font face='Lucida Console'>)</font>
        <b>{</b>
            rectangle temp;
            temp.<font color='#BB00BB'>top</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>=</font> rect.<font color='#BB00BB'>top</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;
            temp.<font color='#BB00BB'>bottom</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>=</font> rect.<font color='#BB00BB'>bottom</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;

            <font color='#0000FF'>const</font> <font color='#0000FF'><u>long</u></font> left_dist <font color='#5555FF'>=</font> rect.<font color='#BB00BB'>left</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font color='#5555FF'>-</font>window.<font color='#BB00BB'>left</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;

            temp.<font color='#BB00BB'>right</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>=</font> window.<font color='#BB00BB'>right</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font color='#5555FF'>-</font>left_dist; 
            temp.<font color='#BB00BB'>left</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>  <font color='#5555FF'>=</font> temp.<font color='#BB00BB'>right</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font color='#5555FF'>-</font>rect.<font color='#BB00BB'>width</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font color='#5555FF'>+</font><font color='#979000'>1</font>; 
            <font color='#0000FF'>return</font> temp;
        <b>}</b>

        <font color='#0000FF'>inline</font> rectangle <b><a name='tform_object'></a>tform_object</b> <font face='Lucida Console'>(</font>
            <font color='#0000FF'>const</font> point_transform_affine<font color='#5555FF'>&amp;</font> tran,
            <font color='#0000FF'>const</font> rectangle<font color='#5555FF'>&amp;</font> rect
        <font face='Lucida Console'>)</font>
        <b>{</b>
            <font color='#0000FF'>return</font> <font color='#BB00BB'>centered_rect</font><font face='Lucida Console'>(</font><font color='#BB00BB'>tran</font><font face='Lucida Console'>(</font><font color='#BB00BB'>center</font><font face='Lucida Console'>(</font>rect<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>, rect.<font color='#BB00BB'>width</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>, rect.<font color='#BB00BB'>height</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
        <b>}</b>

        <font color='#0000FF'>inline</font> full_object_detection <b><a name='tform_object'></a>tform_object</b><font face='Lucida Console'>(</font>
            <font color='#0000FF'>const</font> point_transform_affine<font color='#5555FF'>&amp;</font> tran,
            <font color='#0000FF'>const</font> full_object_detection<font color='#5555FF'>&amp;</font> obj
        <font face='Lucida Console'>)</font>
        <b>{</b>
            std::vector<font color='#5555FF'>&lt;</font>point<font color='#5555FF'>&gt;</font> parts; 
            parts.<font color='#BB00BB'>reserve</font><font face='Lucida Console'>(</font>obj.<font color='#BB00BB'>num_parts</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
            <font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> i <font color='#5555FF'>=</font> <font color='#979000'>0</font>; i <font color='#5555FF'>&lt;</font> obj.<font color='#BB00BB'>num_parts</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>; <font color='#5555FF'>+</font><font color='#5555FF'>+</font>i<font face='Lucida Console'>)</font>
            <b>{</b>
                parts.<font color='#BB00BB'>push_back</font><font face='Lucida Console'>(</font><font color='#BB00BB'>tran</font><font face='Lucida Console'>(</font>obj.<font color='#BB00BB'>part</font><font face='Lucida Console'>(</font>i<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
            <b>}</b>
            <font color='#0000FF'>return</font> <font color='#BB00BB'>full_object_detection</font><font face='Lucida Console'>(</font><font color='#BB00BB'>tform_object</font><font face='Lucida Console'>(</font>tran,obj.<font color='#BB00BB'>get_rect</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>, parts<font face='Lucida Console'>)</font>;
        <b>}</b>
    <b>}</b>

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font>
        <font color='#0000FF'>typename</font> image_array_type,
        <font color='#0000FF'>typename</font> T
        <font color='#5555FF'>&gt;</font>
    <font color='#0000FF'><u>void</u></font> <b><a name='add_image_left_right_flips'></a>add_image_left_right_flips</b> <font face='Lucida Console'>(</font>
        image_array_type<font color='#5555FF'>&amp;</font> images,
        std::vector<font color='#5555FF'>&lt;</font>std::vector<font color='#5555FF'>&lt;</font>T<font color='#5555FF'>&gt;</font> <font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> objects
    <font face='Lucida Console'>)</font>
    <b>{</b>
        <font color='#009900'>// make sure requires clause is not broken
</font>        <font color='#BB00BB'>DLIB_ASSERT</font><font face='Lucida Console'>(</font> images.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>=</font><font color='#5555FF'>=</font> objects.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>,
            "<font color='#CC0000'>\t void add_image_left_right_flips()</font>"
            <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t Invalid inputs were given to this function.</font>"
            <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t images.size():  </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> images.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> 
            <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t objects.size(): </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> objects.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> 
            <font face='Lucida Console'>)</font>;

        <font color='#0000FF'>typename</font> image_array_type::value_type temp;
        std::vector<font color='#5555FF'>&lt;</font>T<font color='#5555FF'>&gt;</font> rects;

        <font color='#0000FF'>const</font> <font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> num <font color='#5555FF'>=</font> images.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;
        <font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> j <font color='#5555FF'>=</font> <font color='#979000'>0</font>; j <font color='#5555FF'>&lt;</font> num; <font color='#5555FF'>+</font><font color='#5555FF'>+</font>j<font face='Lucida Console'>)</font>
        <b>{</b>
            <font color='#0000FF'>const</font> point_transform_affine tran <font color='#5555FF'>=</font> <font color='#BB00BB'>flip_image_left_right</font><font face='Lucida Console'>(</font>images[j], temp<font face='Lucida Console'>)</font>;

            rects.<font color='#BB00BB'>clear</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;
            <font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> i <font color='#5555FF'>=</font> <font color='#979000'>0</font>; i <font color='#5555FF'>&lt;</font> objects[j].<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>; <font color='#5555FF'>+</font><font color='#5555FF'>+</font>i<font face='Lucida Console'>)</font>
                rects.<font color='#BB00BB'>push_back</font><font face='Lucida Console'>(</font>impl::<font color='#BB00BB'>tform_object</font><font face='Lucida Console'>(</font>tran, objects[j][i]<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;

            images.<font color='#BB00BB'>push_back</font><font face='Lucida Console'>(</font>temp<font face='Lucida Console'>)</font>;
            objects.<font color='#BB00BB'>push_back</font><font face='Lucida Console'>(</font>rects<font face='Lucida Console'>)</font>;
        <b>}</b>
    <b>}</b>

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font>
        <font color='#0000FF'>typename</font> image_array_type,
        <font color='#0000FF'>typename</font> T,
        <font color='#0000FF'>typename</font> U
        <font color='#5555FF'>&gt;</font>
    <font color='#0000FF'><u>void</u></font> <b><a name='add_image_left_right_flips'></a>add_image_left_right_flips</b> <font face='Lucida Console'>(</font>
        image_array_type<font color='#5555FF'>&amp;</font> images,
        std::vector<font color='#5555FF'>&lt;</font>std::vector<font color='#5555FF'>&lt;</font>T<font color='#5555FF'>&gt;</font> <font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> objects,
        std::vector<font color='#5555FF'>&lt;</font>std::vector<font color='#5555FF'>&lt;</font>U<font color='#5555FF'>&gt;</font> <font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> objects2
    <font face='Lucida Console'>)</font>
    <b>{</b>
        <font color='#009900'>// make sure requires clause is not broken
</font>        <font color='#BB00BB'>DLIB_ASSERT</font><font face='Lucida Console'>(</font> images.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>=</font><font color='#5555FF'>=</font> objects.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>&amp;</font><font color='#5555FF'>&amp;</font>
                     images.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>=</font><font color='#5555FF'>=</font> objects2.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>,
            "<font color='#CC0000'>\t void add_image_left_right_flips()</font>"
            <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t Invalid inputs were given to this function.</font>"
            <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t images.size():   </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> images.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> 
            <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t objects.size():  </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> objects.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> 
            <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t objects2.size(): </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> objects2.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> 
            <font face='Lucida Console'>)</font>;

        <font color='#0000FF'>typename</font> image_array_type::value_type temp;
        std::vector<font color='#5555FF'>&lt;</font>T<font color='#5555FF'>&gt;</font> rects;
        std::vector<font color='#5555FF'>&lt;</font>U<font color='#5555FF'>&gt;</font> rects2;

        <font color='#0000FF'>const</font> <font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> num <font color='#5555FF'>=</font> images.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;
        <font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> j <font color='#5555FF'>=</font> <font color='#979000'>0</font>; j <font color='#5555FF'>&lt;</font> num; <font color='#5555FF'>+</font><font color='#5555FF'>+</font>j<font face='Lucida Console'>)</font>
        <b>{</b>
            <font color='#0000FF'>const</font> point_transform_affine tran <font color='#5555FF'>=</font> <font color='#BB00BB'>flip_image_left_right</font><font face='Lucida Console'>(</font>images[j], temp<font face='Lucida Console'>)</font>;
            images.<font color='#BB00BB'>push_back</font><font face='Lucida Console'>(</font>temp<font face='Lucida Console'>)</font>;

            rects.<font color='#BB00BB'>clear</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;
            <font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> i <font color='#5555FF'>=</font> <font color='#979000'>0</font>; i <font color='#5555FF'>&lt;</font> objects[j].<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>; <font color='#5555FF'>+</font><font color='#5555FF'>+</font>i<font face='Lucida Console'>)</font>
                rects.<font color='#BB00BB'>push_back</font><font face='Lucida Console'>(</font>impl::<font color='#BB00BB'>tform_object</font><font face='Lucida Console'>(</font>tran, objects[j][i]<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
            objects.<font color='#BB00BB'>push_back</font><font face='Lucida Console'>(</font>rects<font face='Lucida Console'>)</font>;

            rects2.<font color='#BB00BB'>clear</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;
            <font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> i <font color='#5555FF'>=</font> <font color='#979000'>0</font>; i <font color='#5555FF'>&lt;</font> objects2[j].<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>; <font color='#5555FF'>+</font><font color='#5555FF'>+</font>i<font face='Lucida Console'>)</font>
                rects2.<font color='#BB00BB'>push_back</font><font face='Lucida Console'>(</font>impl::<font color='#BB00BB'>tform_object</font><font face='Lucida Console'>(</font>tran, objects2[j][i]<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
            objects2.<font color='#BB00BB'>push_back</font><font face='Lucida Console'>(</font>rects2<font face='Lucida Console'>)</font>;
        <b>}</b>
    <b>}</b>

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font><font color='#0000FF'>typename</font> image_array_type<font color='#5555FF'>&gt;</font>
    <font color='#0000FF'><u>void</u></font> <b><a name='flip_image_dataset_left_right'></a>flip_image_dataset_left_right</b> <font face='Lucida Console'>(</font>
        image_array_type<font color='#5555FF'>&amp;</font> images, 
        std::vector<font color='#5555FF'>&lt;</font>std::vector<font color='#5555FF'>&lt;</font>rectangle<font color='#5555FF'>&gt;</font> <font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> objects
    <font face='Lucida Console'>)</font>
    <b>{</b>
        <font color='#009900'>// make sure requires clause is not broken
</font>        <font color='#BB00BB'>DLIB_ASSERT</font><font face='Lucida Console'>(</font> images.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>=</font><font color='#5555FF'>=</font> objects.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>,
            "<font color='#CC0000'>\t void flip_image_dataset_left_right()</font>"
            <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t Invalid inputs were given to this function.</font>"
            <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t images.size():   </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> images.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> 
            <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t objects.size():  </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> objects.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> 
            <font face='Lucida Console'>)</font>;

        <font color='#0000FF'>typename</font> image_array_type::value_type temp;
        <font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> i <font color='#5555FF'>=</font> <font color='#979000'>0</font>; i <font color='#5555FF'>&lt;</font> images.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>; <font color='#5555FF'>+</font><font color='#5555FF'>+</font>i<font face='Lucida Console'>)</font>
        <b>{</b>
            <font color='#BB00BB'>flip_image_left_right</font><font face='Lucida Console'>(</font>images[i], temp<font face='Lucida Console'>)</font>; 
            <font color='#BB00BB'>swap</font><font face='Lucida Console'>(</font>temp,images[i]<font face='Lucida Console'>)</font>;
            <font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> j <font color='#5555FF'>=</font> <font color='#979000'>0</font>; j <font color='#5555FF'>&lt;</font> objects[i].<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>; <font color='#5555FF'>+</font><font color='#5555FF'>+</font>j<font face='Lucida Console'>)</font>
            <b>{</b>
                objects[i][j] <font color='#5555FF'>=</font> impl::<font color='#BB00BB'>flip_rect_left_right</font><font face='Lucida Console'>(</font>objects[i][j], <font color='#BB00BB'>get_rect</font><font face='Lucida Console'>(</font>images[i]<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
            <b>}</b>
        <b>}</b>
    <b>}</b>

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font><font color='#0000FF'>typename</font> image_array_type<font color='#5555FF'>&gt;</font>
    <font color='#0000FF'><u>void</u></font> <b><a name='flip_image_dataset_left_right'></a>flip_image_dataset_left_right</b> <font face='Lucida Console'>(</font>
        image_array_type<font color='#5555FF'>&amp;</font> images, 
        std::vector<font color='#5555FF'>&lt;</font>std::vector<font color='#5555FF'>&lt;</font>rectangle<font color='#5555FF'>&gt;</font> <font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> objects,
        std::vector<font color='#5555FF'>&lt;</font>std::vector<font color='#5555FF'>&lt;</font>rectangle<font color='#5555FF'>&gt;</font> <font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> objects2
    <font face='Lucida Console'>)</font>
    <b>{</b>
        <font color='#009900'>// make sure requires clause is not broken
</font>        <font color='#BB00BB'>DLIB_ASSERT</font><font face='Lucida Console'>(</font> images.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>=</font><font color='#5555FF'>=</font> objects.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>&amp;</font><font color='#5555FF'>&amp;</font>
                     images.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>=</font><font color='#5555FF'>=</font> objects2.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>,
            "<font color='#CC0000'>\t void flip_image_dataset_left_right()</font>"
            <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t Invalid inputs were given to this function.</font>"
            <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t images.size():   </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> images.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> 
            <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t objects.size():  </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> objects.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> 
            <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t objects2.size(): </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> objects2.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> 
            <font face='Lucida Console'>)</font>;

        <font color='#0000FF'>typename</font> image_array_type::value_type temp;
        <font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> i <font color='#5555FF'>=</font> <font color='#979000'>0</font>; i <font color='#5555FF'>&lt;</font> images.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>; <font color='#5555FF'>+</font><font color='#5555FF'>+</font>i<font face='Lucida Console'>)</font>
        <b>{</b>
            <font color='#BB00BB'>flip_image_left_right</font><font face='Lucida Console'>(</font>images[i], temp<font face='Lucida Console'>)</font>; 
            <font color='#BB00BB'>swap</font><font face='Lucida Console'>(</font>temp, images[i]<font face='Lucida Console'>)</font>;
            <font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> j <font color='#5555FF'>=</font> <font color='#979000'>0</font>; j <font color='#5555FF'>&lt;</font> objects[i].<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>; <font color='#5555FF'>+</font><font color='#5555FF'>+</font>j<font face='Lucida Console'>)</font>
            <b>{</b>
                objects[i][j] <font color='#5555FF'>=</font> impl::<font color='#BB00BB'>flip_rect_left_right</font><font face='Lucida Console'>(</font>objects[i][j], <font color='#BB00BB'>get_rect</font><font face='Lucida Console'>(</font>images[i]<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
            <b>}</b>
            <font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> j <font color='#5555FF'>=</font> <font color='#979000'>0</font>; j <font color='#5555FF'>&lt;</font> objects2[i].<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>; <font color='#5555FF'>+</font><font color='#5555FF'>+</font>j<font face='Lucida Console'>)</font>
            <b>{</b>
                objects2[i][j] <font color='#5555FF'>=</font> impl::<font color='#BB00BB'>flip_rect_left_right</font><font face='Lucida Console'>(</font>objects2[i][j], <font color='#BB00BB'>get_rect</font><font face='Lucida Console'>(</font>images[i]<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
            <b>}</b>
        <b>}</b>
    <b>}</b>

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font>
        <font color='#0000FF'>typename</font> pyramid_type,
        <font color='#0000FF'>typename</font> image_array_type
        <font color='#5555FF'>&gt;</font>
    <font color='#0000FF'><u>void</u></font> <b><a name='upsample_image_dataset'></a>upsample_image_dataset</b> <font face='Lucida Console'>(</font>
        image_array_type<font color='#5555FF'>&amp;</font> images,
        std::vector<font color='#5555FF'>&lt;</font>std::vector<font color='#5555FF'>&lt;</font>rectangle<font color='#5555FF'>&gt;</font> <font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> objects
    <font face='Lucida Console'>)</font>
    <b>{</b>
        <font color='#009900'>// make sure requires clause is not broken
</font>        <font color='#BB00BB'>DLIB_ASSERT</font><font face='Lucida Console'>(</font> images.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>=</font><font color='#5555FF'>=</font> objects.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>,
            "<font color='#CC0000'>\t void upsample_image_dataset()</font>"
            <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t Invalid inputs were given to this function.</font>"
            <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t images.size():   </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> images.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> 
            <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t objects.size():  </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> objects.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> 
            <font face='Lucida Console'>)</font>;

        <font color='#0000FF'>typename</font> image_array_type::value_type temp;
        pyramid_type pyr;
        <font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> i <font color='#5555FF'>=</font> <font color='#979000'>0</font>; i <font color='#5555FF'>&lt;</font> images.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>; <font color='#5555FF'>+</font><font color='#5555FF'>+</font>i<font face='Lucida Console'>)</font>
        <b>{</b>
            <font color='#BB00BB'>pyramid_up</font><font face='Lucida Console'>(</font>images[i], temp, pyr<font face='Lucida Console'>)</font>;
            <font color='#BB00BB'>swap</font><font face='Lucida Console'>(</font>temp, images[i]<font face='Lucida Console'>)</font>;
            <font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> j <font color='#5555FF'>=</font> <font color='#979000'>0</font>; j <font color='#5555FF'>&lt;</font> objects[i].<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>; <font color='#5555FF'>+</font><font color='#5555FF'>+</font>j<font face='Lucida Console'>)</font>
            <b>{</b>
                objects[i][j] <font color='#5555FF'>=</font> pyr.<font color='#BB00BB'>rect_up</font><font face='Lucida Console'>(</font>objects[i][j]<font face='Lucida Console'>)</font>;
            <b>}</b>
        <b>}</b>
    <b>}</b>

    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font>
        <font color='#0000FF'>typename</font> pyramid_type,
        <font color='#0000FF'>typename</font> image_array_type
        <font color='#5555FF'>&gt;</font>
    <font color='#0000FF'><u>void</u></font> <b><a name='upsample_image_dataset'></a>upsample_image_dataset</b> <font face='Lucida Console'>(</font>
        image_array_type<font color='#5555FF'>&amp;</font> images,
        std::vector<font color='#5555FF'>&lt;</font>std::vector<font color='#5555FF'>&lt;</font>mmod_rect<font color='#5555FF'>&gt;</font><font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> objects
    <font face='Lucida Console'>)</font>
    <b>{</b>
        <font color='#009900'>// make sure requires clause is not broken
</font>        <font color='#BB00BB'>DLIB_ASSERT</font><font face='Lucida Console'>(</font> images.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>=</font><font color='#5555FF'>=</font> objects.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>,
            "<font color='#CC0000'>\t void upsample_image_dataset()</font>"
            <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t Invalid inputs were given to this function.</font>"
            <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t images.size():   </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> images.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> 
            <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t objects.size():  </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> objects.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> 
            <font face='Lucida Console'>)</font>;

        <font color='#0000FF'>typename</font> image_array_type::value_type temp;
        pyramid_type pyr;
        <font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> i <font color='#5555FF'>=</font> <font color='#979000'>0</font>; i <font color='#5555FF'>&lt;</font> images.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>; <font color='#5555FF'>+</font><font color='#5555FF'>+</font>i<font face='Lucida Console'>)</font>
        <b>{</b>
            <font color='#BB00BB'>pyramid_up</font><font face='Lucida Console'>(</font>images[i], temp, pyr<font face='Lucida Console'>)</font>;
            <font color='#BB00BB'>swap</font><font face='Lucida Console'>(</font>temp, images[i]<font face='Lucida Console'>)</font>;
            <font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> j <font color='#5555FF'>=</font> <font color='#979000'>0</font>; j <font color='#5555FF'>&lt;</font> objects[i].<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>; <font color='#5555FF'>+</font><font color='#5555FF'>+</font>j<font face='Lucida Console'>)</font>
            <b>{</b>
                objects[i][j].rect <font color='#5555FF'>=</font> pyr.<font color='#BB00BB'>rect_up</font><font face='Lucida Console'>(</font>objects[i][j].rect<font face='Lucida Console'>)</font>;
            <b>}</b>
        <b>}</b>
    <b>}</b>

    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font>
        <font color='#0000FF'>typename</font> pyramid_type,
        <font color='#0000FF'>typename</font> image_array_type
        <font color='#5555FF'>&gt;</font>
    <font color='#0000FF'><u>void</u></font> <b><a name='upsample_image_dataset'></a>upsample_image_dataset</b> <font face='Lucida Console'>(</font>
        image_array_type<font color='#5555FF'>&amp;</font> images,
        std::vector<font color='#5555FF'>&lt;</font>std::vector<font color='#5555FF'>&lt;</font>rectangle<font color='#5555FF'>&gt;</font> <font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> objects,
        std::vector<font color='#5555FF'>&lt;</font>std::vector<font color='#5555FF'>&lt;</font>rectangle<font color='#5555FF'>&gt;</font> <font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> objects2 
    <font face='Lucida Console'>)</font>
    <b>{</b>
        <font color='#009900'>// make sure requires clause is not broken
</font>        <font color='#BB00BB'>DLIB_ASSERT</font><font face='Lucida Console'>(</font> images.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>=</font><font color='#5555FF'>=</font> objects.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>&amp;</font><font color='#5555FF'>&amp;</font>
                     images.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>=</font><font color='#5555FF'>=</font> objects2.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>,
            "<font color='#CC0000'>\t void upsample_image_dataset()</font>"
            <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t Invalid inputs were given to this function.</font>"
            <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t images.size():   </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> images.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> 
            <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t objects.size():  </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> objects.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> 
            <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t objects2.size(): </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> objects2.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> 
            <font face='Lucida Console'>)</font>;

        <font color='#0000FF'>typename</font> image_array_type::value_type temp;
        pyramid_type pyr;
        <font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> i <font color='#5555FF'>=</font> <font color='#979000'>0</font>; i <font color='#5555FF'>&lt;</font> images.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>; <font color='#5555FF'>+</font><font color='#5555FF'>+</font>i<font face='Lucida Console'>)</font>
        <b>{</b>
            <font color='#BB00BB'>pyramid_up</font><font face='Lucida Console'>(</font>images[i], temp, pyr<font face='Lucida Console'>)</font>;
            <font color='#BB00BB'>swap</font><font face='Lucida Console'>(</font>temp, images[i]<font face='Lucida Console'>)</font>;
            <font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> j <font color='#5555FF'>=</font> <font color='#979000'>0</font>; j <font color='#5555FF'>&lt;</font> objects[i].<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>; <font color='#5555FF'>+</font><font color='#5555FF'>+</font>j<font face='Lucida Console'>)</font>
            <b>{</b>
                objects[i][j] <font color='#5555FF'>=</font> pyr.<font color='#BB00BB'>rect_up</font><font face='Lucida Console'>(</font>objects[i][j]<font face='Lucida Console'>)</font>;
            <b>}</b>
            <font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> j <font color='#5555FF'>=</font> <font color='#979000'>0</font>; j <font color='#5555FF'>&lt;</font> objects2[i].<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>; <font color='#5555FF'>+</font><font color='#5555FF'>+</font>j<font face='Lucida Console'>)</font>
            <b>{</b>
                objects2[i][j] <font color='#5555FF'>=</font> pyr.<font color='#BB00BB'>rect_up</font><font face='Lucida Console'>(</font>objects2[i][j]<font face='Lucida Console'>)</font>;
            <b>}</b>
        <b>}</b>
    <b>}</b>

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font><font color='#0000FF'>typename</font> image_array_type<font color='#5555FF'>&gt;</font>
    <font color='#0000FF'><u>void</u></font> <b><a name='rotate_image_dataset'></a>rotate_image_dataset</b> <font face='Lucida Console'>(</font>
        <font color='#0000FF'><u>double</u></font> angle,
        image_array_type<font color='#5555FF'>&amp;</font> images,
        std::vector<font color='#5555FF'>&lt;</font>std::vector<font color='#5555FF'>&lt;</font>rectangle<font color='#5555FF'>&gt;</font> <font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> objects
    <font face='Lucida Console'>)</font>
    <b>{</b>
        <font color='#009900'>// make sure requires clause is not broken
</font>        <font color='#BB00BB'>DLIB_ASSERT</font><font face='Lucida Console'>(</font> images.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>=</font><font color='#5555FF'>=</font> objects.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>,
            "<font color='#CC0000'>\t void rotate_image_dataset()</font>"
            <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t Invalid inputs were given to this function.</font>"
            <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t images.size():   </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> images.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> 
            <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t objects.size():  </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> objects.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> 
            <font face='Lucida Console'>)</font>;

        <font color='#0000FF'>typename</font> image_array_type::value_type temp;
        <font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> i <font color='#5555FF'>=</font> <font color='#979000'>0</font>; i <font color='#5555FF'>&lt;</font> images.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>; <font color='#5555FF'>+</font><font color='#5555FF'>+</font>i<font face='Lucida Console'>)</font>
        <b>{</b>
            <font color='#0000FF'>const</font> point_transform_affine tran <font color='#5555FF'>=</font> <font color='#BB00BB'>rotate_image</font><font face='Lucida Console'>(</font>images[i], temp, angle<font face='Lucida Console'>)</font>;
            <font color='#BB00BB'>swap</font><font face='Lucida Console'>(</font>temp, images[i]<font face='Lucida Console'>)</font>;
            <font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> j <font color='#5555FF'>=</font> <font color='#979000'>0</font>; j <font color='#5555FF'>&lt;</font> objects[i].<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>; <font color='#5555FF'>+</font><font color='#5555FF'>+</font>j<font face='Lucida Console'>)</font>
            <b>{</b>
                <font color='#0000FF'>const</font> rectangle rect <font color='#5555FF'>=</font> objects[i][j];
                objects[i][j] <font color='#5555FF'>=</font> <font color='#BB00BB'>centered_rect</font><font face='Lucida Console'>(</font><font color='#BB00BB'>tran</font><font face='Lucida Console'>(</font><font color='#BB00BB'>center</font><font face='Lucida Console'>(</font>rect<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>, rect.<font color='#BB00BB'>width</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>, rect.<font color='#BB00BB'>height</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
            <b>}</b>
        <b>}</b>
    <b>}</b>

    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font><font color='#0000FF'>typename</font> image_array_type<font color='#5555FF'>&gt;</font>
    <font color='#0000FF'><u>void</u></font> <b><a name='rotate_image_dataset'></a>rotate_image_dataset</b> <font face='Lucida Console'>(</font>
        <font color='#0000FF'><u>double</u></font> angle,
        image_array_type<font color='#5555FF'>&amp;</font> images,
        std::vector<font color='#5555FF'>&lt;</font>std::vector<font color='#5555FF'>&lt;</font>rectangle<font color='#5555FF'>&gt;</font> <font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> objects,
        std::vector<font color='#5555FF'>&lt;</font>std::vector<font color='#5555FF'>&lt;</font>rectangle<font color='#5555FF'>&gt;</font> <font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> objects2
    <font face='Lucida Console'>)</font>
    <b>{</b>
        <font color='#009900'>// make sure requires clause is not broken
</font>        <font color='#BB00BB'>DLIB_ASSERT</font><font face='Lucida Console'>(</font> images.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>=</font><font color='#5555FF'>=</font> objects.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>&amp;</font><font color='#5555FF'>&amp;</font>
                     images.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>=</font><font color='#5555FF'>=</font> objects2.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>,
            "<font color='#CC0000'>\t void rotate_image_dataset()</font>"
            <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t Invalid inputs were given to this function.</font>"
            <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t images.size():   </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> images.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> 
            <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t objects.size():  </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> objects.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> 
            <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t objects2.size(): </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> objects2.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> 
            <font face='Lucida Console'>)</font>;

        <font color='#0000FF'>typename</font> image_array_type::value_type temp;
        <font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> i <font color='#5555FF'>=</font> <font color='#979000'>0</font>; i <font color='#5555FF'>&lt;</font> images.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>; <font color='#5555FF'>+</font><font color='#5555FF'>+</font>i<font face='Lucida Console'>)</font>
        <b>{</b>
            <font color='#0000FF'>const</font> point_transform_affine tran <font color='#5555FF'>=</font> <font color='#BB00BB'>rotate_image</font><font face='Lucida Console'>(</font>images[i], temp, angle<font face='Lucida Console'>)</font>;
            <font color='#BB00BB'>swap</font><font face='Lucida Console'>(</font>temp, images[i]<font face='Lucida Console'>)</font>;
            <font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> j <font color='#5555FF'>=</font> <font color='#979000'>0</font>; j <font color='#5555FF'>&lt;</font> objects[i].<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>; <font color='#5555FF'>+</font><font color='#5555FF'>+</font>j<font face='Lucida Console'>)</font>
            <b>{</b>
                <font color='#0000FF'>const</font> rectangle rect <font color='#5555FF'>=</font> objects[i][j];
                objects[i][j] <font color='#5555FF'>=</font> <font color='#BB00BB'>centered_rect</font><font face='Lucida Console'>(</font><font color='#BB00BB'>tran</font><font face='Lucida Console'>(</font><font color='#BB00BB'>center</font><font face='Lucida Console'>(</font>rect<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>, rect.<font color='#BB00BB'>width</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>, rect.<font color='#BB00BB'>height</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
            <b>}</b>
            <font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> j <font color='#5555FF'>=</font> <font color='#979000'>0</font>; j <font color='#5555FF'>&lt;</font> objects2[i].<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>; <font color='#5555FF'>+</font><font color='#5555FF'>+</font>j<font face='Lucida Console'>)</font>
            <b>{</b>
                <font color='#0000FF'>const</font> rectangle rect <font color='#5555FF'>=</font> objects2[i][j];
                objects2[i][j] <font color='#5555FF'>=</font> <font color='#BB00BB'>centered_rect</font><font face='Lucida Console'>(</font><font color='#BB00BB'>tran</font><font face='Lucida Console'>(</font><font color='#BB00BB'>center</font><font face='Lucida Console'>(</font>rect<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>, rect.<font color='#BB00BB'>width</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>, rect.<font color='#BB00BB'>height</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
            <b>}</b>
        <b>}</b>
    <b>}</b>

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font>
        <font color='#0000FF'>typename</font> image_array_type, 
        <font color='#0000FF'>typename</font> EXP, 
        <font color='#0000FF'>typename</font> T, 
        <font color='#0000FF'>typename</font> U
        <font color='#5555FF'>&gt;</font>
    <font color='#0000FF'><u>void</u></font> <b><a name='add_image_rotations'></a>add_image_rotations</b> <font face='Lucida Console'>(</font>
        <font color='#0000FF'>const</font> matrix_exp<font color='#5555FF'>&lt;</font>EXP<font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> angles,
        image_array_type<font color='#5555FF'>&amp;</font> images,
        std::vector<font color='#5555FF'>&lt;</font>std::vector<font color='#5555FF'>&lt;</font>T<font color='#5555FF'>&gt;</font> <font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> objects,
        std::vector<font color='#5555FF'>&lt;</font>std::vector<font color='#5555FF'>&lt;</font>U<font color='#5555FF'>&gt;</font> <font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> objects2
    <font face='Lucida Console'>)</font>
    <b>{</b>
        <font color='#009900'>// make sure requires clause is not broken
</font>        <font color='#BB00BB'>DLIB_ASSERT</font><font face='Lucida Console'>(</font> <font color='#BB00BB'>is_vector</font><font face='Lucida Console'>(</font>angles<font face='Lucida Console'>)</font> <font color='#5555FF'>&amp;</font><font color='#5555FF'>&amp;</font> angles.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>&gt;</font> <font color='#979000'>0</font> <font color='#5555FF'>&amp;</font><font color='#5555FF'>&amp;</font> 
                     images.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>=</font><font color='#5555FF'>=</font> objects.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>&amp;</font><font color='#5555FF'>&amp;</font>
                     images.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>=</font><font color='#5555FF'>=</font> objects2.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>,
            "<font color='#CC0000'>\t void add_image_rotations()</font>"
            <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t Invalid inputs were given to this function.</font>"
            <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t is_vector(angles): </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> <font color='#BB00BB'>is_vector</font><font face='Lucida Console'>(</font>angles<font face='Lucida Console'>)</font> 
            <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t angles.size():     </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> angles.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> 
            <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t images.size():     </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> images.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> 
            <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t objects.size():    </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> objects.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> 
            <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t objects2.size():   </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> objects2.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> 
            <font face='Lucida Console'>)</font>;

        image_array_type new_images;
        std::vector<font color='#5555FF'>&lt;</font>std::vector<font color='#5555FF'>&lt;</font>T<font color='#5555FF'>&gt;</font> <font color='#5555FF'>&gt;</font> new_objects;
        std::vector<font color='#5555FF'>&lt;</font>std::vector<font color='#5555FF'>&lt;</font>U<font color='#5555FF'>&gt;</font> <font color='#5555FF'>&gt;</font> new_objects2;

        <font color='#0000FF'>using</font> <font color='#0000FF'>namespace</font> impl; 

        std::vector<font color='#5555FF'>&lt;</font>T<font color='#5555FF'>&gt;</font> objtemp;
        std::vector<font color='#5555FF'>&lt;</font>U<font color='#5555FF'>&gt;</font> objtemp2;
        <font color='#0000FF'>typename</font> image_array_type::value_type temp;
        <font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>long</u></font> i <font color='#5555FF'>=</font> <font color='#979000'>0</font>; i <font color='#5555FF'>&lt;</font> angles.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>; <font color='#5555FF'>+</font><font color='#5555FF'>+</font>i<font face='Lucida Console'>)</font>
        <b>{</b>
            <font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> j <font color='#5555FF'>=</font> <font color='#979000'>0</font>; j <font color='#5555FF'>&lt;</font> images.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>; <font color='#5555FF'>+</font><font color='#5555FF'>+</font>j<font face='Lucida Console'>)</font>
            <b>{</b>
                <font color='#0000FF'>const</font> point_transform_affine tran <font color='#5555FF'>=</font> <font color='#BB00BB'>rotate_image</font><font face='Lucida Console'>(</font>images[j], temp, <font color='#BB00BB'>angles</font><font face='Lucida Console'>(</font>i<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
                new_images.<font color='#BB00BB'>push_back</font><font face='Lucida Console'>(</font>temp<font face='Lucida Console'>)</font>;

                objtemp.<font color='#BB00BB'>clear</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;
                <font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> k <font color='#5555FF'>=</font> <font color='#979000'>0</font>; k <font color='#5555FF'>&lt;</font> objects[j].<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>; <font color='#5555FF'>+</font><font color='#5555FF'>+</font>k<font face='Lucida Console'>)</font>
                    objtemp.<font color='#BB00BB'>push_back</font><font face='Lucida Console'>(</font><font color='#BB00BB'>tform_object</font><font face='Lucida Console'>(</font>tran, objects[j][k]<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
                new_objects.<font color='#BB00BB'>push_back</font><font face='Lucida Console'>(</font>objtemp<font face='Lucida Console'>)</font>;

                objtemp2.<font color='#BB00BB'>clear</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;
                <font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> k <font color='#5555FF'>=</font> <font color='#979000'>0</font>; k <font color='#5555FF'>&lt;</font> objects2[j].<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>; <font color='#5555FF'>+</font><font color='#5555FF'>+</font>k<font face='Lucida Console'>)</font>
                    objtemp2.<font color='#BB00BB'>push_back</font><font face='Lucida Console'>(</font><font color='#BB00BB'>tform_object</font><font face='Lucida Console'>(</font>tran, objects2[j][k]<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
                new_objects2.<font color='#BB00BB'>push_back</font><font face='Lucida Console'>(</font>objtemp2<font face='Lucida Console'>)</font>;
            <b>}</b>
        <b>}</b>

        new_images.<font color='#BB00BB'>swap</font><font face='Lucida Console'>(</font>images<font face='Lucida Console'>)</font>;
        new_objects.<font color='#BB00BB'>swap</font><font face='Lucida Console'>(</font>objects<font face='Lucida Console'>)</font>;
        new_objects2.<font color='#BB00BB'>swap</font><font face='Lucida Console'>(</font>objects2<font face='Lucida Console'>)</font>;
    <b>}</b>

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font>
        <font color='#0000FF'>typename</font> image_array_type, 
        <font color='#0000FF'>typename</font> EXP,
        <font color='#0000FF'>typename</font> T
        <font color='#5555FF'>&gt;</font>
    <font color='#0000FF'><u>void</u></font> <b><a name='add_image_rotations'></a>add_image_rotations</b> <font face='Lucida Console'>(</font>
        <font color='#0000FF'>const</font> matrix_exp<font color='#5555FF'>&lt;</font>EXP<font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> angles,
        image_array_type<font color='#5555FF'>&amp;</font> images,
        std::vector<font color='#5555FF'>&lt;</font>std::vector<font color='#5555FF'>&lt;</font>T<font color='#5555FF'>&gt;</font> <font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> objects
    <font face='Lucida Console'>)</font>
    <b>{</b>
        std::vector<font color='#5555FF'>&lt;</font>std::vector<font color='#5555FF'>&lt;</font>T<font color='#5555FF'>&gt;</font> <font color='#5555FF'>&gt;</font> <font color='#BB00BB'>objects2</font><font face='Lucida Console'>(</font>objects.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
        <font color='#BB00BB'>add_image_rotations</font><font face='Lucida Console'>(</font>angles, images, objects, objects2<font face='Lucida Console'>)</font>;
    <b>}</b>

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font><font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font>
        <font color='#0000FF'>typename</font> image_type1,
        <font color='#0000FF'>typename</font> image_type2,
        <font color='#0000FF'>typename</font> pyramid_type,
        <font color='#0000FF'>typename</font> interpolation_type
        <font color='#5555FF'>&gt;</font>
    <font color='#0000FF'><u>void</u></font> <b><a name='pyramid_up'></a>pyramid_up</b> <font face='Lucida Console'>(</font>
        <font color='#0000FF'>const</font> image_type1<font color='#5555FF'>&amp;</font> in_img,
        image_type2<font color='#5555FF'>&amp;</font> out_img,
        <font color='#0000FF'>const</font> pyramid_type<font color='#5555FF'>&amp;</font> pyr,
        <font color='#0000FF'>const</font> interpolation_type<font color='#5555FF'>&amp;</font> interp
    <font face='Lucida Console'>)</font>
    <b>{</b>
        <font color='#009900'>// make sure requires clause is not broken
</font>        <font color='#BB00BB'>DLIB_ASSERT</font><font face='Lucida Console'>(</font> <font color='#BB00BB'>is_same_object</font><font face='Lucida Console'>(</font>in_img, out_img<font face='Lucida Console'>)</font> <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>false</font> ,
            "<font color='#CC0000'>\t void pyramid_up()</font>"
            <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t Invalid inputs were given to this function.</font>"
            <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t is_same_object(in_img, out_img):  </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> <font color='#BB00BB'>is_same_object</font><font face='Lucida Console'>(</font>in_img, out_img<font face='Lucida Console'>)</font>
            <font face='Lucida Console'>)</font>;

        <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font><font color='#BB00BB'>image_size</font><font face='Lucida Console'>(</font>in_img<font face='Lucida Console'>)</font> <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>0</font><font face='Lucida Console'>)</font>
        <b>{</b>
            <font color='#BB00BB'>set_image_size</font><font face='Lucida Console'>(</font>out_img, <font color='#979000'>0</font>, <font color='#979000'>0</font><font face='Lucida Console'>)</font>;
            <font color='#0000FF'>return</font>;
        <b>}</b>

        rectangle rect <font color='#5555FF'>=</font> <font color='#BB00BB'>get_rect</font><font face='Lucida Console'>(</font>in_img<font face='Lucida Console'>)</font>;
        rectangle uprect <font color='#5555FF'>=</font> pyr.<font color='#BB00BB'>rect_up</font><font face='Lucida Console'>(</font>rect<font face='Lucida Console'>)</font>;
        <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>uprect.<font color='#BB00BB'>is_empty</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>
        <b>{</b>
            <font color='#BB00BB'>set_image_size</font><font face='Lucida Console'>(</font>out_img, <font color='#979000'>0</font>, <font color='#979000'>0</font><font face='Lucida Console'>)</font>;
            <font color='#0000FF'>return</font>;
        <b>}</b>
        <font color='#BB00BB'>set_image_size</font><font face='Lucida Console'>(</font>out_img, uprect.<font color='#BB00BB'>bottom</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font color='#5555FF'>+</font><font color='#979000'>1</font>, uprect.<font color='#BB00BB'>right</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font color='#5555FF'>+</font><font color='#979000'>1</font><font face='Lucida Console'>)</font>;

        <font color='#BB00BB'>resize_image</font><font face='Lucida Console'>(</font>in_img, out_img, interp<font face='Lucida Console'>)</font>;
    <b>}</b>

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font>
        <font color='#0000FF'>typename</font> image_type1,
        <font color='#0000FF'>typename</font> image_type2,
        <font color='#0000FF'>typename</font> pyramid_type
        <font color='#5555FF'>&gt;</font>
    <font color='#0000FF'><u>void</u></font> <b><a name='pyramid_up'></a>pyramid_up</b> <font face='Lucida Console'>(</font>
        <font color='#0000FF'>const</font> image_type1<font color='#5555FF'>&amp;</font> in_img,
        image_type2<font color='#5555FF'>&amp;</font> out_img,
        <font color='#0000FF'>const</font> pyramid_type<font color='#5555FF'>&amp;</font> pyr
    <font face='Lucida Console'>)</font>
    <b>{</b>
        <font color='#009900'>// make sure requires clause is not broken
</font>        <font color='#BB00BB'>DLIB_ASSERT</font><font face='Lucida Console'>(</font> <font color='#BB00BB'>is_same_object</font><font face='Lucida Console'>(</font>in_img, out_img<font face='Lucida Console'>)</font> <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>false</font> ,
            "<font color='#CC0000'>\t void pyramid_up()</font>"
            <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t Invalid inputs were given to this function.</font>"
            <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t is_same_object(in_img, out_img):  </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> <font color='#BB00BB'>is_same_object</font><font face='Lucida Console'>(</font>in_img, out_img<font face='Lucida Console'>)</font>
            <font face='Lucida Console'>)</font>;

        <font color='#BB00BB'>pyramid_up</font><font face='Lucida Console'>(</font>in_img, out_img, pyr, <font color='#BB00BB'>interpolate_bilinear</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
    <b>}</b>

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font>
        <font color='#0000FF'>typename</font> image_type,
        <font color='#0000FF'>typename</font> pyramid_type
        <font color='#5555FF'>&gt;</font>
    <font color='#0000FF'><u>void</u></font> <b><a name='pyramid_up'></a>pyramid_up</b> <font face='Lucida Console'>(</font>
        image_type<font color='#5555FF'>&amp;</font> img,
        <font color='#0000FF'>const</font> pyramid_type<font color='#5555FF'>&amp;</font> pyr
    <font face='Lucida Console'>)</font>
    <b>{</b>
        image_type temp;
        <font color='#BB00BB'>pyramid_up</font><font face='Lucida Console'>(</font>img, temp, pyr<font face='Lucida Console'>)</font>;
        <font color='#BB00BB'>swap</font><font face='Lucida Console'>(</font>temp, img<font face='Lucida Console'>)</font>;
    <b>}</b>

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font>
        <font color='#0000FF'>typename</font> image_type
        <font color='#5555FF'>&gt;</font>
    <font color='#0000FF'><u>void</u></font> <b><a name='pyramid_up'></a>pyramid_up</b> <font face='Lucida Console'>(</font>
        image_type<font color='#5555FF'>&amp;</font> img
    <font face='Lucida Console'>)</font>
    <b>{</b>
        pyramid_down<font color='#5555FF'>&lt;</font><font color='#979000'>2</font><font color='#5555FF'>&gt;</font> pyr;
        <font color='#BB00BB'>pyramid_up</font><font face='Lucida Console'>(</font>img, pyr<font face='Lucida Console'>)</font>;
    <b>}</b>

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font><font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
    <font color='#0000FF'>struct</font> <b><a name='chip_dims'></a>chip_dims</b>
    <b>{</b>
        <b><a name='chip_dims'></a>chip_dims</b> <font face='Lucida Console'>(</font>
            <font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> rows_,
            <font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> cols_
        <font face='Lucida Console'>)</font> : rows<font face='Lucida Console'>(</font>rows_<font face='Lucida Console'>)</font>, cols<font face='Lucida Console'>(</font>cols_<font face='Lucida Console'>)</font> <b>{</b> <b>}</b>

        <font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> rows;
        <font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> cols;
    <b>}</b>;

    <font color='#0000FF'>struct</font> <b><a name='chip_details'></a>chip_details</b>
    <b>{</b>
        <b><a name='chip_details'></a>chip_details</b><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> : angle<font face='Lucida Console'>(</font><font color='#979000'>0</font><font face='Lucida Console'>)</font>, rows<font face='Lucida Console'>(</font><font color='#979000'>0</font><font face='Lucida Console'>)</font>, cols<font face='Lucida Console'>(</font><font color='#979000'>0</font><font face='Lucida Console'>)</font> <b>{</b><b>}</b>
        <b><a name='chip_details'></a>chip_details</b><font face='Lucida Console'>(</font><font color='#0000FF'>const</font> rectangle<font color='#5555FF'>&amp;</font> rect_<font face='Lucida Console'>)</font> : rect<font face='Lucida Console'>(</font>rect_<font face='Lucida Console'>)</font>,angle<font face='Lucida Console'>(</font><font color='#979000'>0</font><font face='Lucida Console'>)</font>, rows<font face='Lucida Console'>(</font>rect_.height<font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>, cols<font face='Lucida Console'>(</font>rect_.width<font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font> <b>{</b><b>}</b>
        <b><a name='chip_details'></a>chip_details</b><font face='Lucida Console'>(</font><font color='#0000FF'>const</font> drectangle<font color='#5555FF'>&amp;</font> rect_<font face='Lucida Console'>)</font> : rect<font face='Lucida Console'>(</font>rect_<font face='Lucida Console'>)</font>,angle<font face='Lucida Console'>(</font><font color='#979000'>0</font><font face='Lucida Console'>)</font>, 
          rows<font face='Lucida Console'>(</font><font face='Lucida Console'>(</font><font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font><font face='Lucida Console'>)</font><font face='Lucida Console'>(</font>rect_.height<font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font color='#5555FF'>+</font><font color='#979000'>0.5</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>, cols<font face='Lucida Console'>(</font><font face='Lucida Console'>(</font><font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font><font face='Lucida Console'>)</font><font face='Lucida Console'>(</font>rect_.width<font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font color='#5555FF'>+</font><font color='#979000'>0.5</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font> <b>{</b><b>}</b>
        <b><a name='chip_details'></a>chip_details</b><font face='Lucida Console'>(</font><font color='#0000FF'>const</font> drectangle<font color='#5555FF'>&amp;</font> rect_, <font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> size<font face='Lucida Console'>)</font> : rect<font face='Lucida Console'>(</font>rect_<font face='Lucida Console'>)</font>,angle<font face='Lucida Console'>(</font><font color='#979000'>0</font><font face='Lucida Console'>)</font> 
        <b>{</b> <font color='#BB00BB'>compute_dims_from_size</font><font face='Lucida Console'>(</font>size<font face='Lucida Console'>)</font>; <b>}</b>
        <b><a name='chip_details'></a>chip_details</b><font face='Lucida Console'>(</font><font color='#0000FF'>const</font> drectangle<font color='#5555FF'>&amp;</font> rect_, <font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> size, <font color='#0000FF'><u>double</u></font> angle_<font face='Lucida Console'>)</font> : rect<font face='Lucida Console'>(</font>rect_<font face='Lucida Console'>)</font>,angle<font face='Lucida Console'>(</font>angle_<font face='Lucida Console'>)</font> 
        <b>{</b> <font color='#BB00BB'>compute_dims_from_size</font><font face='Lucida Console'>(</font>size<font face='Lucida Console'>)</font>; <b>}</b>

        <b><a name='chip_details'></a>chip_details</b><font face='Lucida Console'>(</font><font color='#0000FF'>const</font> drectangle<font color='#5555FF'>&amp;</font> rect_, <font color='#0000FF'>const</font> chip_dims<font color='#5555FF'>&amp;</font> dims<font face='Lucida Console'>)</font> : 
            rect<font face='Lucida Console'>(</font>rect_<font face='Lucida Console'>)</font>,angle<font face='Lucida Console'>(</font><font color='#979000'>0</font><font face='Lucida Console'>)</font>,rows<font face='Lucida Console'>(</font>dims.rows<font face='Lucida Console'>)</font>, cols<font face='Lucida Console'>(</font>dims.cols<font face='Lucida Console'>)</font> <b>{</b><b>}</b>
        <b><a name='chip_details'></a>chip_details</b><font face='Lucida Console'>(</font><font color='#0000FF'>const</font> drectangle<font color='#5555FF'>&amp;</font> rect_, <font color='#0000FF'>const</font> chip_dims<font color='#5555FF'>&amp;</font> dims, <font color='#0000FF'><u>double</u></font> angle_<font face='Lucida Console'>)</font> : 
            rect<font face='Lucida Console'>(</font>rect_<font face='Lucida Console'>)</font>,angle<font face='Lucida Console'>(</font>angle_<font face='Lucida Console'>)</font>,rows<font face='Lucida Console'>(</font>dims.rows<font face='Lucida Console'>)</font>, cols<font face='Lucida Console'>(</font>dims.cols<font face='Lucida Console'>)</font> <b>{</b><b>}</b>

        <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font><font color='#0000FF'>typename</font> T<font color='#5555FF'>&gt;</font>
        <b><a name='chip_details'></a>chip_details</b><font face='Lucida Console'>(</font>
            <font color='#0000FF'>const</font> std::vector<font color='#5555FF'>&lt;</font>dlib::vector<font color='#5555FF'>&lt;</font>T,<font color='#979000'>2</font><font color='#5555FF'>&gt;</font> <font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> chip_points,
            <font color='#0000FF'>const</font> std::vector<font color='#5555FF'>&lt;</font>dlib::vector<font color='#5555FF'>&lt;</font>T,<font color='#979000'>2</font><font color='#5555FF'>&gt;</font> <font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> img_points,
            <font color='#0000FF'>const</font> chip_dims<font color='#5555FF'>&amp;</font> dims
        <font face='Lucida Console'>)</font> : 
            rows<font face='Lucida Console'>(</font>dims.rows<font face='Lucida Console'>)</font>, cols<font face='Lucida Console'>(</font>dims.cols<font face='Lucida Console'>)</font> 
        <b>{</b>
            <font color='#BB00BB'>DLIB_CASSERT</font><font face='Lucida Console'>(</font> chip_points.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>=</font><font color='#5555FF'>=</font> img_points.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>&amp;</font><font color='#5555FF'>&amp;</font> chip_points.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>&gt;</font><font color='#5555FF'>=</font> <font color='#979000'>2</font>,
                "<font color='#CC0000'>\t chip_details::chip_details(chip_points,img_points,dims)</font>"
                <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t Invalid inputs were given to this function.</font>"
                <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t chip_points.size(): </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> chip_points.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> 
                <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t img_points.size():  </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> img_points.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> 
            <font face='Lucida Console'>)</font>;

            <font color='#0000FF'>const</font> point_transform_affine tform <font color='#5555FF'>=</font> <font color='#BB00BB'>find_similarity_transform</font><font face='Lucida Console'>(</font>chip_points,img_points<font face='Lucida Console'>)</font>;
            dlib::vector<font color='#5555FF'>&lt;</font><font color='#0000FF'><u>double</u></font>,<font color='#979000'>2</font><font color='#5555FF'>&gt;</font> <font color='#BB00BB'>p</font><font face='Lucida Console'>(</font><font color='#979000'>1</font>,<font color='#979000'>0</font><font face='Lucida Console'>)</font>;
            p <font color='#5555FF'>=</font> tform.<font color='#BB00BB'>get_m</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font color='#5555FF'>*</font>p;

            <font color='#009900'>// There are only 3 things happening in a similarity transform.  There is a
</font>            <font color='#009900'>// rescaling, a rotation, and a translation.  So here we pick out the scale and
</font>            <font color='#009900'>// rotation parameters.
</font>            angle <font color='#5555FF'>=</font> std::<font color='#BB00BB'>atan2</font><font face='Lucida Console'>(</font>p.<font color='#BB00BB'>y</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>,p.<font color='#BB00BB'>x</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
            <font color='#009900'>// Note that the translation and scale part are represented by the extraction
</font>            <font color='#009900'>// rectangle.  So here we build the appropriate rectangle.
</font>            <font color='#0000FF'>const</font> <font color='#0000FF'><u>double</u></font> scale <font color='#5555FF'>=</font> <font color='#BB00BB'>length</font><font face='Lucida Console'>(</font>p<font face='Lucida Console'>)</font>; 
            rect <font color='#5555FF'>=</font> <font color='#BB00BB'>centered_drect</font><font face='Lucida Console'>(</font><font color='#BB00BB'>tform</font><font face='Lucida Console'>(</font><font color='#BB00BB'>point</font><font face='Lucida Console'>(</font>dims.cols,dims.rows<font face='Lucida Console'>)</font><font color='#5555FF'>/</font><font color='#979000'>2.0</font><font face='Lucida Console'>)</font>, 
                                  dims.cols<font color='#5555FF'>*</font>scale, 
                                  dims.rows<font color='#5555FF'>*</font>scale<font face='Lucida Console'>)</font>;
        <b>}</b>


        drectangle rect;
        <font color='#0000FF'><u>double</u></font> angle;
        <font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> rows; 
        <font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> cols;

        <font color='#0000FF'>inline</font> <font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> <b><a name='size'></a>size</b><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#0000FF'>const</font> 
        <b>{</b>
            <font color='#0000FF'>return</font> rows<font color='#5555FF'>*</font>cols;
        <b>}</b>

    <font color='#0000FF'>private</font>:
        <font color='#0000FF'><u>void</u></font> <b><a name='compute_dims_from_size'></a>compute_dims_from_size</b> <font face='Lucida Console'>(</font>
            <font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> size
        <font face='Lucida Console'>)</font> 
        <b>{</b>
            <font color='#0000FF'>const</font> <font color='#0000FF'><u>double</u></font> relative_size <font color='#5555FF'>=</font> std::<font color='#BB00BB'>sqrt</font><font face='Lucida Console'>(</font>size<font color='#5555FF'>/</font><font face='Lucida Console'>(</font><font color='#0000FF'><u>double</u></font><font face='Lucida Console'>)</font>rect.<font color='#BB00BB'>area</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
            rows <font color='#5555FF'>=</font> <font color='#0000FF'>static_cast</font><font color='#5555FF'>&lt;</font><font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font><font color='#5555FF'>&gt;</font><font face='Lucida Console'>(</font>rect.<font color='#BB00BB'>height</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font color='#5555FF'>*</font>relative_size <font color='#5555FF'>+</font> <font color='#979000'>0.5</font><font face='Lucida Console'>)</font>;
            cols  <font color='#5555FF'>=</font> <font color='#0000FF'>static_cast</font><font color='#5555FF'>&lt;</font><font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font><font color='#5555FF'>&gt;</font><font face='Lucida Console'>(</font>size<font color='#5555FF'>/</font><font face='Lucida Console'>(</font><font color='#0000FF'><u>double</u></font><font face='Lucida Console'>)</font>rows <font color='#5555FF'>+</font> <font color='#979000'>0.5</font><font face='Lucida Console'>)</font>;
            rows <font color='#5555FF'>=</font> std::<font color='#BB00BB'>max</font><font face='Lucida Console'>(</font><font color='#979000'>1</font>ul,rows<font face='Lucida Console'>)</font>;
            cols <font color='#5555FF'>=</font> std::<font color='#BB00BB'>max</font><font face='Lucida Console'>(</font><font color='#979000'>1</font>ul,cols<font face='Lucida Console'>)</font>;
        <b>}</b>
    <b>}</b>;

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
    <font color='#0000FF'>inline</font> point_transform_affine <b><a name='get_mapping_to_chip'></a>get_mapping_to_chip</b> <font face='Lucida Console'>(</font>
        <font color='#0000FF'>const</font> chip_details<font color='#5555FF'>&amp;</font> details
    <font face='Lucida Console'>)</font>
    <b>{</b>
        std::vector<font color='#5555FF'>&lt;</font>dlib::vector<font color='#5555FF'>&lt;</font><font color='#0000FF'><u>double</u></font>,<font color='#979000'>2</font><font color='#5555FF'>&gt;</font> <font color='#5555FF'>&gt;</font> from, to;
        point <font color='#BB00BB'>p1</font><font face='Lucida Console'>(</font><font color='#979000'>0</font>,<font color='#979000'>0</font><font face='Lucida Console'>)</font>;
        point <font color='#BB00BB'>p2</font><font face='Lucida Console'>(</font>details.cols<font color='#5555FF'>-</font><font color='#979000'>1</font>,<font color='#979000'>0</font><font face='Lucida Console'>)</font>;
        point <font color='#BB00BB'>p3</font><font face='Lucida Console'>(</font>details.cols<font color='#5555FF'>-</font><font color='#979000'>1</font>, details.rows<font color='#5555FF'>-</font><font color='#979000'>1</font><font face='Lucida Console'>)</font>;
        to.<font color='#BB00BB'>push_back</font><font face='Lucida Console'>(</font>p1<font face='Lucida Console'>)</font>;  
        from.<font color='#BB00BB'>push_back</font><font face='Lucida Console'>(</font>rotate_point<font color='#5555FF'>&lt;</font><font color='#0000FF'><u>double</u></font><font color='#5555FF'>&gt;</font><font face='Lucida Console'>(</font><font color='#BB00BB'>center</font><font face='Lucida Console'>(</font>details.rect<font face='Lucida Console'>)</font>,details.rect.<font color='#BB00BB'>tl_corner</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>,details.angle<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
        to.<font color='#BB00BB'>push_back</font><font face='Lucida Console'>(</font>p2<font face='Lucida Console'>)</font>;  
        from.<font color='#BB00BB'>push_back</font><font face='Lucida Console'>(</font>rotate_point<font color='#5555FF'>&lt;</font><font color='#0000FF'><u>double</u></font><font color='#5555FF'>&gt;</font><font face='Lucida Console'>(</font><font color='#BB00BB'>center</font><font face='Lucida Console'>(</font>details.rect<font face='Lucida Console'>)</font>,details.rect.<font color='#BB00BB'>tr_corner</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>,details.angle<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
        to.<font color='#BB00BB'>push_back</font><font face='Lucida Console'>(</font>p3<font face='Lucida Console'>)</font>;  
        from.<font color='#BB00BB'>push_back</font><font face='Lucida Console'>(</font>rotate_point<font color='#5555FF'>&lt;</font><font color='#0000FF'><u>double</u></font><font color='#5555FF'>&gt;</font><font face='Lucida Console'>(</font><font color='#BB00BB'>center</font><font face='Lucida Console'>(</font>details.rect<font face='Lucida Console'>)</font>,details.rect.<font color='#BB00BB'>br_corner</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>,details.angle<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
        <font color='#0000FF'>return</font> <font color='#BB00BB'>find_affine_transform</font><font face='Lucida Console'>(</font>from, to<font face='Lucida Console'>)</font>;
    <b>}</b>

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
    <font color='#0000FF'>inline</font> full_object_detection <b><a name='map_det_to_chip'></a>map_det_to_chip</b><font face='Lucida Console'>(</font>
        <font color='#0000FF'>const</font> full_object_detection<font color='#5555FF'>&amp;</font> det,
        <font color='#0000FF'>const</font> chip_details<font color='#5555FF'>&amp;</font> details
    <font face='Lucida Console'>)</font>
    <b>{</b>
        point_transform_affine tform <font color='#5555FF'>=</font> <font color='#BB00BB'>get_mapping_to_chip</font><font face='Lucida Console'>(</font>details<font face='Lucida Console'>)</font>;
        full_object_detection <font color='#BB00BB'>res</font><font face='Lucida Console'>(</font>det<font face='Lucida Console'>)</font>;
        <font color='#009900'>// map the parts
</font>        <font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> l <font color='#5555FF'>=</font> <font color='#979000'>0</font>; l <font color='#5555FF'>&lt;</font> det.<font color='#BB00BB'>num_parts</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>; <font color='#5555FF'>+</font><font color='#5555FF'>+</font>l<font face='Lucida Console'>)</font>
            res.<font color='#BB00BB'>part</font><font face='Lucida Console'>(</font>l<font face='Lucida Console'>)</font> <font color='#5555FF'>=</font> <font color='#BB00BB'>tform</font><font face='Lucida Console'>(</font>det.<font color='#BB00BB'>part</font><font face='Lucida Console'>(</font>l<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
        <font color='#009900'>// map the main rectangle
</font>        rectangle rect;
        rect <font color='#5555FF'>+</font><font color='#5555FF'>=</font> <font color='#BB00BB'>tform</font><font face='Lucida Console'>(</font>det.<font color='#BB00BB'>get_rect</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>.<font color='#BB00BB'>tl_corner</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
        rect <font color='#5555FF'>+</font><font color='#5555FF'>=</font> <font color='#BB00BB'>tform</font><font face='Lucida Console'>(</font>det.<font color='#BB00BB'>get_rect</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>.<font color='#BB00BB'>tr_corner</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
        rect <font color='#5555FF'>+</font><font color='#5555FF'>=</font> <font color='#BB00BB'>tform</font><font face='Lucida Console'>(</font>det.<font color='#BB00BB'>get_rect</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>.<font color='#BB00BB'>bl_corner</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
        rect <font color='#5555FF'>+</font><font color='#5555FF'>=</font> <font color='#BB00BB'>tform</font><font face='Lucida Console'>(</font>det.<font color='#BB00BB'>get_rect</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>.<font color='#BB00BB'>br_corner</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
        res.<font color='#BB00BB'>get_rect</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>=</font> rect;
        <font color='#0000FF'>return</font> res;
    <b>}</b>

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
    <font color='#0000FF'>namespace</font> impl
    <b>{</b>
        <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font>
            <font color='#0000FF'>typename</font> image_type1,
            <font color='#0000FF'>typename</font> image_type2
            <font color='#5555FF'>&gt;</font>
        <font color='#0000FF'><u>void</u></font> <b><a name='basic_extract_image_chip'></a>basic_extract_image_chip</b> <font face='Lucida Console'>(</font>
            <font color='#0000FF'>const</font> image_type1<font color='#5555FF'>&amp;</font> img,
            <font color='#0000FF'>const</font> rectangle<font color='#5555FF'>&amp;</font> location,
            image_type2<font color='#5555FF'>&amp;</font> chip
        <font face='Lucida Console'>)</font>
        <font color='#009900'>/*!
            ensures
                - This function doesn't do any scaling or rotating. It just pulls out the
                  chip in the given rectangle.  This also means the output image has the
                  same dimensions as the location rectangle.
        !*/</font>
        <b>{</b>
            const_image_view<font color='#5555FF'>&lt;</font>image_type1<font color='#5555FF'>&gt;</font> <font color='#BB00BB'>vimg</font><font face='Lucida Console'>(</font>img<font face='Lucida Console'>)</font>;
            image_view<font color='#5555FF'>&lt;</font>image_type2<font color='#5555FF'>&gt;</font> <font color='#BB00BB'>vchip</font><font face='Lucida Console'>(</font>chip<font face='Lucida Console'>)</font>;

            vchip.<font color='#BB00BB'>set_size</font><font face='Lucida Console'>(</font>location.<font color='#BB00BB'>height</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>, location.<font color='#BB00BB'>width</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;

            <font color='#009900'>// location might go outside img so clip it
</font>            rectangle area <font color='#5555FF'>=</font> location.<font color='#BB00BB'>intersect</font><font face='Lucida Console'>(</font><font color='#BB00BB'>get_rect</font><font face='Lucida Console'>(</font>img<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;

            <font color='#009900'>// find the part of the chip that corresponds to area in img.
</font>            rectangle chip_area <font color='#5555FF'>=</font> <font color='#BB00BB'>translate_rect</font><font face='Lucida Console'>(</font>area, <font color='#5555FF'>-</font>location.<font color='#BB00BB'>tl_corner</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;

            <font color='#BB00BB'>zero_border_pixels</font><font face='Lucida Console'>(</font>chip, chip_area<font face='Lucida Console'>)</font>;
            <font color='#009900'>// now pull out the contents of area/chip_area.
</font>            <font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>long</u></font> r <font color='#5555FF'>=</font> chip_area.<font color='#BB00BB'>top</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>, rr <font color='#5555FF'>=</font> area.<font color='#BB00BB'>top</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>; r <font color='#5555FF'>&lt;</font><font color='#5555FF'>=</font> chip_area.<font color='#BB00BB'>bottom</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>; <font color='#5555FF'>+</font><font color='#5555FF'>+</font>r,<font color='#5555FF'>+</font><font color='#5555FF'>+</font>rr<font face='Lucida Console'>)</font>
            <b>{</b>
                <font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>long</u></font> c <font color='#5555FF'>=</font> chip_area.<font color='#BB00BB'>left</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>, cc <font color='#5555FF'>=</font> area.<font color='#BB00BB'>left</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>; c <font color='#5555FF'>&lt;</font><font color='#5555FF'>=</font> chip_area.<font color='#BB00BB'>right</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>; <font color='#5555FF'>+</font><font color='#5555FF'>+</font>c,<font color='#5555FF'>+</font><font color='#5555FF'>+</font>cc<font face='Lucida Console'>)</font>
                <b>{</b>
                    <font color='#BB00BB'>assign_pixel</font><font face='Lucida Console'>(</font>vchip[r][c], vimg[rr][cc]<font face='Lucida Console'>)</font>;
                <b>}</b>
            <b>}</b>
        <b>}</b>
    <b>}</b>

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font>
        <font color='#0000FF'>typename</font> image_type1,
        <font color='#0000FF'>typename</font> image_type2
        <font color='#5555FF'>&gt;</font>
    <font color='#0000FF'><u>void</u></font> <b><a name='extract_image_chips'></a>extract_image_chips</b> <font face='Lucida Console'>(</font>
        <font color='#0000FF'>const</font> image_type1<font color='#5555FF'>&amp;</font> img,
        <font color='#0000FF'>const</font> std::vector<font color='#5555FF'>&lt;</font>chip_details<font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> chip_locations,
        dlib::array<font color='#5555FF'>&lt;</font>image_type2<font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> chips
    <font face='Lucida Console'>)</font>
    <b>{</b>
        <font color='#009900'>// make sure requires clause is not broken
</font><font color='#0000FF'>#ifdef</font> ENABLE_ASSERTS
        <font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> i <font color='#5555FF'>=</font> <font color='#979000'>0</font>; i <font color='#5555FF'>&lt;</font> chip_locations.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>; <font color='#5555FF'>+</font><font color='#5555FF'>+</font>i<font face='Lucida Console'>)</font>
        <b>{</b>
            <font color='#BB00BB'>DLIB_CASSERT</font><font face='Lucida Console'>(</font>chip_locations[i].<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>!</font><font color='#5555FF'>=</font> <font color='#979000'>0</font> <font color='#5555FF'>&amp;</font><font color='#5555FF'>&amp;</font>
                         chip_locations[i].rect.<font color='#BB00BB'>is_empty</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>false</font>,
            "<font color='#CC0000'>\t void extract_image_chips()</font>"
            <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t Invalid inputs were given to this function.</font>"
            <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t chip_locations[</font>"<font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font>i<font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font>"<font color='#CC0000'>].size():            </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> chip_locations[i].<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>
            <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t chip_locations[</font>"<font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font>i<font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font>"<font color='#CC0000'>].rect.is_empty(): </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> chip_locations[i].rect.<font color='#BB00BB'>is_empty</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>
            <font face='Lucida Console'>)</font>;
        <b>}</b>
<font color='#0000FF'>#endif</font> 

        pyramid_down<font color='#5555FF'>&lt;</font><font color='#979000'>2</font><font color='#5555FF'>&gt;</font> pyr;
        <font color='#0000FF'><u>long</u></font> max_depth <font color='#5555FF'>=</font> <font color='#979000'>0</font>;
        <font color='#009900'>// If the chip is supposed to be much smaller than the source subwindow then you
</font>        <font color='#009900'>// can't just extract it using bilinear interpolation since at a high enough
</font>        <font color='#009900'>// downsampling amount it would effectively turn into nearest neighbor
</font>        <font color='#009900'>// interpolation.  So we use an image pyramid to make sure the interpolation is
</font>        <font color='#009900'>// fast but also high quality.  The first thing we do is figure out how deep the
</font>        <font color='#009900'>// image pyramid needs to be.
</font>        rectangle bounding_box;
        <font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> i <font color='#5555FF'>=</font> <font color='#979000'>0</font>; i <font color='#5555FF'>&lt;</font> chip_locations.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>; <font color='#5555FF'>+</font><font color='#5555FF'>+</font>i<font face='Lucida Console'>)</font>
        <b>{</b>
            <font color='#0000FF'><u>long</u></font> depth <font color='#5555FF'>=</font> <font color='#979000'>0</font>;
            <font color='#0000FF'><u>double</u></font> grow <font color='#5555FF'>=</font> <font color='#979000'>2</font>;
            drectangle rect <font color='#5555FF'>=</font> pyr.<font color='#BB00BB'>rect_down</font><font face='Lucida Console'>(</font>chip_locations[i].rect<font face='Lucida Console'>)</font>;
            <font color='#0000FF'>while</font> <font face='Lucida Console'>(</font>rect.<font color='#BB00BB'>area</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>&gt;</font> chip_locations[i].<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>
            <b>{</b>
                rect <font color='#5555FF'>=</font> pyr.<font color='#BB00BB'>rect_down</font><font face='Lucida Console'>(</font>rect<font face='Lucida Console'>)</font>;
                <font color='#5555FF'>+</font><font color='#5555FF'>+</font>depth;
                <font color='#009900'>// We drop the image size by a factor of 2 each iteration and then assume a
</font>                <font color='#009900'>// border of 2 pixels is needed to avoid any border effects of the crop.
</font>                grow <font color='#5555FF'>=</font> grow<font color='#5555FF'>*</font><font color='#979000'>2</font> <font color='#5555FF'>+</font> <font color='#979000'>2</font>;
            <b>}</b>
            drectangle rot_rect;
            <font color='#0000FF'>const</font> vector<font color='#5555FF'>&lt;</font><font color='#0000FF'><u>double</u></font>,<font color='#979000'>2</font><font color='#5555FF'>&gt;</font> cent <font color='#5555FF'>=</font> <font color='#BB00BB'>center</font><font face='Lucida Console'>(</font>chip_locations[i].rect<font face='Lucida Console'>)</font>;
            rot_rect <font color='#5555FF'>+</font><font color='#5555FF'>=</font> rotate_point<font color='#5555FF'>&lt;</font><font color='#0000FF'><u>double</u></font><font color='#5555FF'>&gt;</font><font face='Lucida Console'>(</font>cent,chip_locations[i].rect.<font color='#BB00BB'>tl_corner</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>,chip_locations[i].angle<font face='Lucida Console'>)</font>;
            rot_rect <font color='#5555FF'>+</font><font color='#5555FF'>=</font> rotate_point<font color='#5555FF'>&lt;</font><font color='#0000FF'><u>double</u></font><font color='#5555FF'>&gt;</font><font face='Lucida Console'>(</font>cent,chip_locations[i].rect.<font color='#BB00BB'>tr_corner</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>,chip_locations[i].angle<font face='Lucida Console'>)</font>;
            rot_rect <font color='#5555FF'>+</font><font color='#5555FF'>=</font> rotate_point<font color='#5555FF'>&lt;</font><font color='#0000FF'><u>double</u></font><font color='#5555FF'>&gt;</font><font face='Lucida Console'>(</font>cent,chip_locations[i].rect.<font color='#BB00BB'>bl_corner</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>,chip_locations[i].angle<font face='Lucida Console'>)</font>;
            rot_rect <font color='#5555FF'>+</font><font color='#5555FF'>=</font> rotate_point<font color='#5555FF'>&lt;</font><font color='#0000FF'><u>double</u></font><font color='#5555FF'>&gt;</font><font face='Lucida Console'>(</font>cent,chip_locations[i].rect.<font color='#BB00BB'>br_corner</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>,chip_locations[i].angle<font face='Lucida Console'>)</font>;
            bounding_box <font color='#5555FF'>+</font><font color='#5555FF'>=</font> <font color='#BB00BB'>grow_rect</font><font face='Lucida Console'>(</font>rot_rect, grow<font face='Lucida Console'>)</font>.<font color='#BB00BB'>intersect</font><font face='Lucida Console'>(</font><font color='#BB00BB'>get_rect</font><font face='Lucida Console'>(</font>img<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
            max_depth <font color='#5555FF'>=</font> std::<font color='#BB00BB'>max</font><font face='Lucida Console'>(</font>depth,max_depth<font face='Lucida Console'>)</font>;
        <b>}</b>
        <font color='#009900'>//std::cout &lt;&lt; "max_depth: " &lt;&lt; max_depth &lt;&lt; std::endl;
</font>        <font color='#009900'>//std::cout &lt;&lt; "crop amount: " &lt;&lt; bounding_box.area()/(double)get_rect(img).area() &lt;&lt; std::endl;
</font>
        <font color='#009900'>// now make an image pyramid
</font>        dlib::array<font color='#5555FF'>&lt;</font>array2d<font color='#5555FF'>&lt;</font><font color='#0000FF'>typename</font> image_traits<font color='#5555FF'>&lt;</font>image_type1<font color='#5555FF'>&gt;</font>::pixel_type<font color='#5555FF'>&gt;</font> <font color='#5555FF'>&gt;</font> <font color='#BB00BB'>levels</font><font face='Lucida Console'>(</font>max_depth<font face='Lucida Console'>)</font>;
        <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>levels.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>!</font><font color='#5555FF'>=</font> <font color='#979000'>0</font><font face='Lucida Console'>)</font>
            <font color='#BB00BB'>pyr</font><font face='Lucida Console'>(</font><font color='#BB00BB'>sub_image</font><font face='Lucida Console'>(</font>img,bounding_box<font face='Lucida Console'>)</font>,levels[<font color='#979000'>0</font>]<font face='Lucida Console'>)</font>;
        <font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> i <font color='#5555FF'>=</font> <font color='#979000'>1</font>; i <font color='#5555FF'>&lt;</font> levels.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>; <font color='#5555FF'>+</font><font color='#5555FF'>+</font>i<font face='Lucida Console'>)</font>
            <font color='#BB00BB'>pyr</font><font face='Lucida Console'>(</font>levels[i<font color='#5555FF'>-</font><font color='#979000'>1</font>],levels[i]<font face='Lucida Console'>)</font>;

        std::vector<font color='#5555FF'>&lt;</font>dlib::vector<font color='#5555FF'>&lt;</font><font color='#0000FF'><u>double</u></font>,<font color='#979000'>2</font><font color='#5555FF'>&gt;</font> <font color='#5555FF'>&gt;</font> from, to;

        <font color='#009900'>// now pull out the chips
</font>        chips.<font color='#BB00BB'>resize</font><font face='Lucida Console'>(</font>chip_locations.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
        <font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> i <font color='#5555FF'>=</font> <font color='#979000'>0</font>; i <font color='#5555FF'>&lt;</font> chips.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>; <font color='#5555FF'>+</font><font color='#5555FF'>+</font>i<font face='Lucida Console'>)</font>
        <b>{</b>
            <font color='#009900'>// If the chip doesn't have any rotation or scaling then use the basic version
</font>            <font color='#009900'>// of chip extraction that just does a fast copy.
</font>            <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>chip_locations[i].angle <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>0</font> <font color='#5555FF'>&amp;</font><font color='#5555FF'>&amp;</font> 
                chip_locations[i].rows <font color='#5555FF'>=</font><font color='#5555FF'>=</font> chip_locations[i].rect.<font color='#BB00BB'>height</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>&amp;</font><font color='#5555FF'>&amp;</font>
                chip_locations[i].cols <font color='#5555FF'>=</font><font color='#5555FF'>=</font> chip_locations[i].rect.<font color='#BB00BB'>width</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>
            <b>{</b>
                impl::<font color='#BB00BB'>basic_extract_image_chip</font><font face='Lucida Console'>(</font>img, chip_locations[i].rect, chips[i]<font face='Lucida Console'>)</font>;
            <b>}</b>
            <font color='#0000FF'>else</font>
            <b>{</b>
                <font color='#BB00BB'>set_image_size</font><font face='Lucida Console'>(</font>chips[i], chip_locations[i].rows, chip_locations[i].cols<font face='Lucida Console'>)</font>;

                <font color='#009900'>// figure out which level in the pyramid to use to extract the chip
</font>                <font color='#0000FF'><u>int</u></font> level <font color='#5555FF'>=</font> <font color='#5555FF'>-</font><font color='#979000'>1</font>;
                drectangle rect <font color='#5555FF'>=</font> <font color='#BB00BB'>translate_rect</font><font face='Lucida Console'>(</font>chip_locations[i].rect, <font color='#5555FF'>-</font>bounding_box.<font color='#BB00BB'>tl_corner</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
                <font color='#0000FF'>while</font> <font face='Lucida Console'>(</font>pyr.<font color='#BB00BB'>rect_down</font><font face='Lucida Console'>(</font>rect<font face='Lucida Console'>)</font>.<font color='#BB00BB'>area</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>&gt;</font> chip_locations[i].<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>
                <b>{</b>
                    <font color='#5555FF'>+</font><font color='#5555FF'>+</font>level;
                    rect <font color='#5555FF'>=</font> pyr.<font color='#BB00BB'>rect_down</font><font face='Lucida Console'>(</font>rect<font face='Lucida Console'>)</font>;
                <b>}</b>

                <font color='#009900'>// find the appropriate transformation that maps from the chip to the input
</font>                <font color='#009900'>// image
</font>                from.<font color='#BB00BB'>clear</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;
                to.<font color='#BB00BB'>clear</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;
                from.<font color='#BB00BB'>push_back</font><font face='Lucida Console'>(</font><font color='#BB00BB'>get_rect</font><font face='Lucida Console'>(</font>chips[i]<font face='Lucida Console'>)</font>.<font color='#BB00BB'>tl_corner</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;  to.<font color='#BB00BB'>push_back</font><font face='Lucida Console'>(</font>rotate_point<font color='#5555FF'>&lt;</font><font color='#0000FF'><u>double</u></font><font color='#5555FF'>&gt;</font><font face='Lucida Console'>(</font><font color='#BB00BB'>center</font><font face='Lucida Console'>(</font>rect<font face='Lucida Console'>)</font>,rect.<font color='#BB00BB'>tl_corner</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>,chip_locations[i].angle<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
                from.<font color='#BB00BB'>push_back</font><font face='Lucida Console'>(</font><font color='#BB00BB'>get_rect</font><font face='Lucida Console'>(</font>chips[i]<font face='Lucida Console'>)</font>.<font color='#BB00BB'>tr_corner</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;  to.<font color='#BB00BB'>push_back</font><font face='Lucida Console'>(</font>rotate_point<font color='#5555FF'>&lt;</font><font color='#0000FF'><u>double</u></font><font color='#5555FF'>&gt;</font><font face='Lucida Console'>(</font><font color='#BB00BB'>center</font><font face='Lucida Console'>(</font>rect<font face='Lucida Console'>)</font>,rect.<font color='#BB00BB'>tr_corner</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>,chip_locations[i].angle<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
                from.<font color='#BB00BB'>push_back</font><font face='Lucida Console'>(</font><font color='#BB00BB'>get_rect</font><font face='Lucida Console'>(</font>chips[i]<font face='Lucida Console'>)</font>.<font color='#BB00BB'>bl_corner</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;  to.<font color='#BB00BB'>push_back</font><font face='Lucida Console'>(</font>rotate_point<font color='#5555FF'>&lt;</font><font color='#0000FF'><u>double</u></font><font color='#5555FF'>&gt;</font><font face='Lucida Console'>(</font><font color='#BB00BB'>center</font><font face='Lucida Console'>(</font>rect<font face='Lucida Console'>)</font>,rect.<font color='#BB00BB'>bl_corner</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>,chip_locations[i].angle<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
                point_transform_affine trns <font color='#5555FF'>=</font> <font color='#BB00BB'>find_affine_transform</font><font face='Lucida Console'>(</font>from,to<font face='Lucida Console'>)</font>;

                <font color='#009900'>// now extract the actual chip
</font>                <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>level <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#5555FF'>-</font><font color='#979000'>1</font><font face='Lucida Console'>)</font>
                    <font color='#BB00BB'>transform_image</font><font face='Lucida Console'>(</font><font color='#BB00BB'>sub_image</font><font face='Lucida Console'>(</font>img,bounding_box<font face='Lucida Console'>)</font>,chips[i],<font color='#BB00BB'>interpolate_bilinear</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>,trns<font face='Lucida Console'>)</font>;
                <font color='#0000FF'>else</font>
                    <font color='#BB00BB'>transform_image</font><font face='Lucida Console'>(</font>levels[level],chips[i],<font color='#BB00BB'>interpolate_bilinear</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>,trns<font face='Lucida Console'>)</font>;
            <b>}</b>
        <b>}</b>
    <b>}</b>

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font>
        <font color='#0000FF'>typename</font> image_type1,
        <font color='#0000FF'>typename</font> image_type2
        <font color='#5555FF'>&gt;</font>
    <font color='#0000FF'><u>void</u></font> <b><a name='extract_image_chip'></a>extract_image_chip</b> <font face='Lucida Console'>(</font>
        <font color='#0000FF'>const</font> image_type1<font color='#5555FF'>&amp;</font> img,
        <font color='#0000FF'>const</font> chip_details<font color='#5555FF'>&amp;</font> location,
        image_type2<font color='#5555FF'>&amp;</font> chip
    <font face='Lucida Console'>)</font>
    <b>{</b>
        <font color='#009900'>// If the chip doesn't have any rotation or scaling then use the basic version of
</font>        <font color='#009900'>// chip extraction that just does a fast copy.
</font>        <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>location.angle <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>0</font> <font color='#5555FF'>&amp;</font><font color='#5555FF'>&amp;</font> 
            location.rows <font color='#5555FF'>=</font><font color='#5555FF'>=</font> location.rect.<font color='#BB00BB'>height</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>&amp;</font><font color='#5555FF'>&amp;</font>
            location.cols <font color='#5555FF'>=</font><font color='#5555FF'>=</font> location.rect.<font color='#BB00BB'>width</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>
        <b>{</b>
            impl::<font color='#BB00BB'>basic_extract_image_chip</font><font face='Lucida Console'>(</font>img, location.rect, chip<font face='Lucida Console'>)</font>;
        <b>}</b>
        <font color='#0000FF'>else</font>
        <b>{</b>
            std::vector<font color='#5555FF'>&lt;</font>chip_details<font color='#5555FF'>&gt;</font> <font color='#BB00BB'>chip_locations</font><font face='Lucida Console'>(</font><font color='#979000'>1</font>,location<font face='Lucida Console'>)</font>;
            dlib::array<font color='#5555FF'>&lt;</font>image_type2<font color='#5555FF'>&gt;</font> chips;
            <font color='#BB00BB'>extract_image_chips</font><font face='Lucida Console'>(</font>img, chip_locations, chips<font face='Lucida Console'>)</font>;
            <font color='#BB00BB'>swap</font><font face='Lucida Console'>(</font>chips[<font color='#979000'>0</font>], chip<font face='Lucida Console'>)</font>;
        <b>}</b>
    <b>}</b>

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
    <font color='#0000FF'>inline</font> chip_details <b><a name='get_face_chip_details'></a>get_face_chip_details</b> <font face='Lucida Console'>(</font>
        <font color='#0000FF'>const</font> full_object_detection<font color='#5555FF'>&amp;</font> det,
        <font color='#0000FF'>const</font> <font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> size <font color='#5555FF'>=</font> <font color='#979000'>200</font>,
        <font color='#0000FF'>const</font> <font color='#0000FF'><u>double</u></font> padding <font color='#5555FF'>=</font> <font color='#979000'>0.2</font>
    <font face='Lucida Console'>)</font>
    <b>{</b>
        <font color='#BB00BB'>DLIB_CASSERT</font><font face='Lucida Console'>(</font>det.<font color='#BB00BB'>num_parts</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>68</font>,
            "<font color='#CC0000'>\t chip_details get_face_chip_details()</font>"
            <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t You must give a detection with exactly 68 parts in it.</font>"
            <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t det.num_parts(): </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> det.<font color='#BB00BB'>num_parts</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>
        <font face='Lucida Console'>)</font>;
        <font color='#BB00BB'>DLIB_CASSERT</font><font face='Lucida Console'>(</font>padding <font color='#5555FF'>&gt;</font><font color='#5555FF'>=</font> <font color='#979000'>0</font> <font color='#5555FF'>&amp;</font><font color='#5555FF'>&amp;</font> size <font color='#5555FF'>&gt;</font> <font color='#979000'>0</font>,
            "<font color='#CC0000'>\t chip_details get_face_chip_details()</font>"
            <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t Invalid inputs were given to this function.</font>"
            <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t padding: </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> padding 
            <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t size:    </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> size 
            <font face='Lucida Console'>)</font>;

        <font color='#009900'>// Average positions of face points 17-67
</font>        <font color='#0000FF'>const</font> <font color='#0000FF'><u>double</u></font> mean_face_shape_x[] <font color='#5555FF'>=</font> <b>{</b>
            <font color='#979000'>0.000213256</font>, <font color='#979000'>0.0752622</font>, <font color='#979000'>0.18113</font>, <font color='#979000'>0.29077</font>, <font color='#979000'>0.393397</font>, <font color='#979000'>0.586856</font>, <font color='#979000'>0.689483</font>, <font color='#979000'>0.799124</font>,
            <font color='#979000'>0.904991</font>, <font color='#979000'>0.98004</font>, <font color='#979000'>0.490127</font>, <font color='#979000'>0.490127</font>, <font color='#979000'>0.490127</font>, <font color='#979000'>0.490127</font>, <font color='#979000'>0.36688</font>, <font color='#979000'>0.426036</font>,
            <font color='#979000'>0.490127</font>, <font color='#979000'>0.554217</font>, <font color='#979000'>0.613373</font>, <font color='#979000'>0.121737</font>, <font color='#979000'>0.187122</font>, <font color='#979000'>0.265825</font>, <font color='#979000'>0.334606</font>, <font color='#979000'>0.260918</font>,
            <font color='#979000'>0.182743</font>, <font color='#979000'>0.645647</font>, <font color='#979000'>0.714428</font>, <font color='#979000'>0.793132</font>, <font color='#979000'>0.858516</font>, <font color='#979000'>0.79751</font>, <font color='#979000'>0.719335</font>, <font color='#979000'>0.254149</font>,
            <font color='#979000'>0.340985</font>, <font color='#979000'>0.428858</font>, <font color='#979000'>0.490127</font>, <font color='#979000'>0.551395</font>, <font color='#979000'>0.639268</font>, <font color='#979000'>0.726104</font>, <font color='#979000'>0.642159</font>, <font color='#979000'>0.556721</font>,
            <font color='#979000'>0.490127</font>, <font color='#979000'>0.423532</font>, <font color='#979000'>0.338094</font>, <font color='#979000'>0.290379</font>, <font color='#979000'>0.428096</font>, <font color='#979000'>0.490127</font>, <font color='#979000'>0.552157</font>, <font color='#979000'>0.689874</font>,
            <font color='#979000'>0.553364</font>, <font color='#979000'>0.490127</font>, <font color='#979000'>0.42689</font>
        <b>}</b>;
        <font color='#0000FF'>const</font> <font color='#0000FF'><u>double</u></font> mean_face_shape_y[] <font color='#5555FF'>=</font> <b>{</b>
            <font color='#979000'>0.106454</font>, <font color='#979000'>0.038915</font>, <font color='#979000'>0.0187482</font>, <font color='#979000'>0.0344891</font>, <font color='#979000'>0.0773906</font>, <font color='#979000'>0.0773906</font>, <font color='#979000'>0.0344891</font>,
            <font color='#979000'>0.0187482</font>, <font color='#979000'>0.038915</font>, <font color='#979000'>0.106454</font>, <font color='#979000'>0.203352</font>, <font color='#979000'>0.307009</font>, <font color='#979000'>0.409805</font>, <font color='#979000'>0.515625</font>, <font color='#979000'>0.587326</font>,
            <font color='#979000'>0.609345</font>, <font color='#979000'>0.628106</font>, <font color='#979000'>0.609345</font>, <font color='#979000'>0.587326</font>, <font color='#979000'>0.216423</font>, <font color='#979000'>0.178758</font>, <font color='#979000'>0.179852</font>, <font color='#979000'>0.231733</font>,
            <font color='#979000'>0.245099</font>, <font color='#979000'>0.244077</font>, <font color='#979000'>0.231733</font>, <font color='#979000'>0.179852</font>, <font color='#979000'>0.178758</font>, <font color='#979000'>0.216423</font>, <font color='#979000'>0.244077</font>, <font color='#979000'>0.245099</font>,
            <font color='#979000'>0.780233</font>, <font color='#979000'>0.745405</font>, <font color='#979000'>0.727388</font>, <font color='#979000'>0.742578</font>, <font color='#979000'>0.727388</font>, <font color='#979000'>0.745405</font>, <font color='#979000'>0.780233</font>, <font color='#979000'>0.864805</font>,
            <font color='#979000'>0.902192</font>, <font color='#979000'>0.909281</font>, <font color='#979000'>0.902192</font>, <font color='#979000'>0.864805</font>, <font color='#979000'>0.784792</font>, <font color='#979000'>0.778746</font>, <font color='#979000'>0.785343</font>, <font color='#979000'>0.778746</font>,
            <font color='#979000'>0.784792</font>, <font color='#979000'>0.824182</font>, <font color='#979000'>0.831803</font>, <font color='#979000'>0.824182</font>
        <b>}</b>;

        <font color='#BB00BB'>COMPILE_TIME_ASSERT</font><font face='Lucida Console'>(</font><font color='#0000FF'>sizeof</font><font face='Lucida Console'>(</font>mean_face_shape_x<font face='Lucida Console'>)</font><font color='#5555FF'>/</font><font color='#0000FF'>sizeof</font><font face='Lucida Console'>(</font><font color='#0000FF'><u>double</u></font><font face='Lucida Console'>)</font> <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>68</font><font color='#5555FF'>-</font><font color='#979000'>17</font><font face='Lucida Console'>)</font>;

        std::vector<font color='#5555FF'>&lt;</font>dlib::vector<font color='#5555FF'>&lt;</font><font color='#0000FF'><u>double</u></font>,<font color='#979000'>2</font><font color='#5555FF'>&gt;</font> <font color='#5555FF'>&gt;</font> from_points, to_points;
        <font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> i <font color='#5555FF'>=</font> <font color='#979000'>17</font>; i <font color='#5555FF'>&lt;</font> det.<font color='#BB00BB'>num_parts</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>; <font color='#5555FF'>+</font><font color='#5555FF'>+</font>i<font face='Lucida Console'>)</font>
        <b>{</b>
            <font color='#009900'>// Ignore the lower lip
</font>            <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font><font face='Lucida Console'>(</font><font color='#979000'>55</font> <font color='#5555FF'>&lt;</font><font color='#5555FF'>=</font> i <font color='#5555FF'>&amp;</font><font color='#5555FF'>&amp;</font> i <font color='#5555FF'>&lt;</font><font color='#5555FF'>=</font> <font color='#979000'>59</font><font face='Lucida Console'>)</font> <font color='#5555FF'>|</font><font color='#5555FF'>|</font> <font face='Lucida Console'>(</font><font color='#979000'>65</font> <font color='#5555FF'>&lt;</font><font color='#5555FF'>=</font> i <font color='#5555FF'>&amp;</font><font color='#5555FF'>&amp;</font> i <font color='#5555FF'>&lt;</font><font color='#5555FF'>=</font> <font color='#979000'>67</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>
                <font color='#0000FF'>continue</font>;
            <font color='#009900'>// Ignore the eyebrows 
</font>            <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font><font color='#979000'>17</font> <font color='#5555FF'>&lt;</font><font color='#5555FF'>=</font> i <font color='#5555FF'>&amp;</font><font color='#5555FF'>&amp;</font> i <font color='#5555FF'>&lt;</font><font color='#5555FF'>=</font> <font color='#979000'>26</font><font face='Lucida Console'>)</font>
                <font color='#0000FF'>continue</font>;

            dlib::vector<font color='#5555FF'>&lt;</font><font color='#0000FF'><u>double</u></font>,<font color='#979000'>2</font><font color='#5555FF'>&gt;</font> p;
            p.<font color='#BB00BB'>x</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>=</font> <font face='Lucida Console'>(</font>padding<font color='#5555FF'>+</font>mean_face_shape_x[i<font color='#5555FF'>-</font><font color='#979000'>17</font>]<font face='Lucida Console'>)</font><font color='#5555FF'>/</font><font face='Lucida Console'>(</font><font color='#979000'>2</font><font color='#5555FF'>*</font>padding<font color='#5555FF'>+</font><font color='#979000'>1</font><font face='Lucida Console'>)</font>;
            p.<font color='#BB00BB'>y</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>=</font> <font face='Lucida Console'>(</font>padding<font color='#5555FF'>+</font>mean_face_shape_y[i<font color='#5555FF'>-</font><font color='#979000'>17</font>]<font face='Lucida Console'>)</font><font color='#5555FF'>/</font><font face='Lucida Console'>(</font><font color='#979000'>2</font><font color='#5555FF'>*</font>padding<font color='#5555FF'>+</font><font color='#979000'>1</font><font face='Lucida Console'>)</font>;
            from_points.<font color='#BB00BB'>push_back</font><font face='Lucida Console'>(</font>p<font color='#5555FF'>*</font>size<font face='Lucida Console'>)</font>;
            to_points.<font color='#BB00BB'>push_back</font><font face='Lucida Console'>(</font>det.<font color='#BB00BB'>part</font><font face='Lucida Console'>(</font>i<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
        <b>}</b>

        <font color='#0000FF'>return</font> <font color='#BB00BB'>chip_details</font><font face='Lucida Console'>(</font>from_points, to_points, <font color='#BB00BB'>chip_dims</font><font face='Lucida Console'>(</font>size,size<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
    <b>}</b>

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
    <font color='#0000FF'>inline</font> std::vector<font color='#5555FF'>&lt;</font>chip_details<font color='#5555FF'>&gt;</font> <b><a name='get_face_chip_details'></a>get_face_chip_details</b> <font face='Lucida Console'>(</font>
        <font color='#0000FF'>const</font> std::vector<font color='#5555FF'>&lt;</font>full_object_detection<font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> dets,
        <font color='#0000FF'>const</font> <font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> size <font color='#5555FF'>=</font> <font color='#979000'>200</font>,
        <font color='#0000FF'>const</font> <font color='#0000FF'><u>double</u></font> padding <font color='#5555FF'>=</font> <font color='#979000'>0.2</font>
    <font face='Lucida Console'>)</font>
    <b>{</b>
        std::vector<font color='#5555FF'>&lt;</font>chip_details<font color='#5555FF'>&gt;</font> res;
        res.<font color='#BB00BB'>reserve</font><font face='Lucida Console'>(</font>dets.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
        <font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> i <font color='#5555FF'>=</font> <font color='#979000'>0</font>; i <font color='#5555FF'>&lt;</font> dets.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>; <font color='#5555FF'>+</font><font color='#5555FF'>+</font>i<font face='Lucida Console'>)</font>
            res.<font color='#BB00BB'>push_back</font><font face='Lucida Console'>(</font><font color='#BB00BB'>get_face_chip_details</font><font face='Lucida Console'>(</font>dets[i], size, padding<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
        <font color='#0000FF'>return</font> res;
    <b>}</b>

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
<b>}</b>

<font color='#0000FF'>#endif</font> <font color='#009900'>// DLIB_INTERPOlATIONh_
</font>

</pre></body></html>